Powershell issue while running match

I’ve done all the necessary steps and tried to run scripts\run_match.ps1, and a bunch of errors pop up after each turn (errors are more or less identical)

74 P1 {“p2Units”:[[],[],[],[],[],[],[]],“turnInfo”:[1,73,0],“p1Stats”:[30.0,317.0,35.4,0],“p1Units”:[[],[],[],[],[],[],[]],“p2Stats”:[30.0,317.0,35.4,0],“events”:{“selfDestruct”:[],“breach”:[],“damage”:[],“shield”:[],“move”:[],“spawn”:[],“death”:[],“attack”:[],“melee”:[]}}
Invalid command, couldn’t json for player 0 : {“p2Units”:[[],[],[],[],[],[],[]],“turnInfo”:[1,73,0],“p1Stats”:[30.0,317.0,35.4,0],“p1Units”:[[],[],[],[],[],[],[]],“p2Stats”:[30.0,317.0,35.4,0],“events”:{“selfDestruct”:[],“breach”:[],“damage”:[],“shield”:[],“move”:[],“spawn”:[],“death”:[],“attack”:[],“melee”:[]}}
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path at com.google.gson.Gson.fromJson(Gson.java:891) at com.google.gson.Gson.fromJson(Gson.java:844) at com.google.gson.Gson.fromJson(Gson.java:793) at towergame.Parser.processInputForPlayer(Parser.java:179) at towergame.Parser.processInputBuild(Parser.java:165) at towergame.GameMain.runLoop(GameMain.java:346) at towergame.GameMain.startGame(GameMain.java:202) at towergame.GameMain.main(GameMain.java:175) at towerworker.TowerWorker.main(TowerWorker.java:78) Caused by: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path
at com.google.gson.stream.JsonReader.beginArray(JsonReader.java:351)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:80)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61)
at com.google.gson.Gson.fromJson(Gson.java:879)
… 8 more

This is testing with the base starter algo, no modifications whatsoever. Help would be appreciated, thanks in advance.

1 Like

Here’s what fixed it for me

In your algorithm’s folder, edit run.ps1
Change the line that says “py -3 $algoPath”
to
“python $algoPath”

1 Like

I tried your fix, didn’t work for me.

I’m pretty certain it has something to do with the “java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $” error that pops up twice after each round.

EDIT: I changed the ‘python’ back to ‘py -3’ and it started working again. idk why but it seems to have fixed it.

2 Likes

@RuberCuber that could possibly be an issue with your Python’s PATH variables or multiple versions installed (which would be a problem with PATH variables). If you try typing into a cmd window (or powershell) and only one command (py or python) works then I would check the Python environment variables for your OS. I also would recommend making sure modules install properly to your ...\Python36\Lib\site-packages directory whenever you use pip3 install [module].

If you don’t have any issues you should be fine continuing to use it how you are.

1 Like

removing the ‘-3’ from the ‘py -3 $algoPath’ command in the run.ps1 file worked for me

I experienced this error when i had a print() function, instead i used gamelib.debug_write(print_this) and this fixed the problem for me

1 Like