Local run not working on Windows

Hello. When I run my scripts/run_match.ps1 it runs using the starter algorithm, declares a winner, generates a replay, everything, but A) in the replay neither bot actually performs any actions and B) it shows these errors for each turn despite finishing & working:

Starting turn: 98
98 P1 {"p2Units":[[],[],[],[],[],[],[]],"turnInfo":[1,97,0],"p1Stats":[30.0,413.0,41.9,3],"p1Units":[[],[],[],[],[],[],[]],"p2Stats":[30.0,413.0,41.9,3],"events":{"selfDestruct":[],"breach":[],"damage":[],"shield":[],"move":[],"spawn":[],"death":[],"attack":[],"melee":[]}}
Invalid command, couldn't json for player 0 : {"p2Units":[[],[],[],[],[],[],[]],"turnInfo":[1,97,0],"p1Stats":[30.0,413.0,41.9,3],"p1Units":[[],[],[],[],[],[],[]],"p2Stats":[30.0,413.0,41.9,3],"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:899)
        at com.google.gson.Gson.fromJson(Gson.java:852)
        at com.google.gson.Gson.fromJson(Gson.java:801)
        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:103)
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:350)
        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:887)
        ... 8 more
98 P2 {"p2Units":[[],[],[],[],[],[],[]],"turnInfo":[1,97,0],"p1Stats":[30.0,413.0,41.9,3],"p1Units":[[],[],[],[],[],[],[]],"p2Stats":[30.0,413.0,41.9,3],"events":{"selfDestruct":[],"breach":[],"damage":[],"shield":[],"move":[],"spawn":[],"death":[],"attack":[],"melee":[]}}
Invalid command, couldn't json for player 1 : {"p2Units":[[],[],[],[],[],[],[]],"turnInfo":[1,97,0],"p1Stats":[30.0,413.0,41.9,3],"p1Units":[[],[],[],[],[],[],[]],"p2Stats":[30.0,413.0,41.9,3],"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:899)
        at com.google.gson.Gson.fromJson(Gson.java:852)
        at com.google.gson.Gson.fromJson(Gson.java:801)
        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:103)
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:350)
        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:887)
        ... 8 more
98 P1 {"p2Units":[[],[],[],[],[],[],[]],"turnInfo":[0,98,-1],"p1Stats":[30.0,417.0,41.9,3],"p1Units":[[],[],[],[],[],[],[]],"p2Stats":[30.0,417.0,41.9,3],"events":{"selfDestruct":[],"breach":[],"damage":[],"shield":[],"move":[],"spawn":[],"death":[],"attack":[],"melee":[]}}
Invalid command, couldn't json for player 0 : {"p2Units":[[],[],[],[],[],[],[]],"turnInfo":[0,98,-1],"p1Stats":[30.0,417.0,41.9,3],"p1Units":[[],[],[],[],[],[],[]],"p2Stats":[30.0,417.0,41.9,3],"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:899)
        at com.google.gson.Gson.fromJson(Gson.java:852)
        at com.google.gson.Gson.fromJson(Gson.java:801)
        at towergame.Parser.processInputForPlayer(Parser.java:179)
        at towergame.Parser.processInputDeploy(Parser.java:356)
        at towergame.GameMain.runLoop(GameMain.java:352)
        at towergame.GameMain.startGame(GameMain.java:202)
        at towergame.GameMain.main(GameMain.java:175)
        at towerworker.TowerWorker.main(TowerWorker.java:103)
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:350)
        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:887)
        ... 8 more
98 P2 {"p2Units":[[],[],[],[],[],[],[]],"turnInfo":[0,98,-1],"p1Stats":[30.0,417.0,41.9,3],"p1Units":[[],[],[],[],[],[],[]],"p2Stats":[30.0,417.0,41.9,3],"events":{"selfDestruct":[],"breach":[],"damage":[],"shield":[],"move":[],"spawn":[],"death":[],"attack":[],"melee":[]}}
Invalid command, couldn't json for player 1 : {"p2Units":[[],[],[],[],[],[],[]],"turnInfo":[0,98,-1],"p1Stats":[30.0,417.0,41.9,3],"p1Units":[[],[],[],[],[],[],[]],"p2Stats":[30.0,417.0,41.9,3],"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:899)
        at com.google.gson.Gson.fromJson(Gson.java:852)
        at com.google.gson.Gson.fromJson(Gson.java:801)
        at towergame.Parser.processInputForPlayer(Parser.java:179)
        at towergame.Parser.processInputDeploy(Parser.java:356)
        at towergame.GameMain.runLoop(GameMain.java:352)
        at towergame.GameMain.startGame(GameMain.java:202)
        at towergame.GameMain.main(GameMain.java:175)
        at towerworker.TowerWorker.main(TowerWorker.java:103)
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:350)
        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:887)
        ... 8 more
1 Like

I have exactly the same problem. I managed to fix the json error by using the newest version of the engine and an older version of everything else

1 Like

I had this error aswell, for me this error was caused by using the print() function. Instead use gamelib.debug_write(). I hope it works :slight_smile:

@KassaDiMama
I haven’t used any print() functions :confused:

This is a new error first noticed today. We don’t have an official fix yet, but @colorpoison seems to have an idea about a possible solution. We will be investigating this on monday.

yeah but my solution only solved the json error. The algos still don’t perform any actions

Based on your previous comment I thought you had a complete fix, but I see the miscommunication. No worries, we will be looking into this.

Hi,
has there been any progress regarding this particular error? I am getting it constantly as well…

@keuapar
I had the guy in charge of CLI stuff take a look at in on monday, not sure if progress has been made. You can try pulling/dowloading the most recent starterkit and checking out the troubleshooting section, or playing the game on the site for now.

Sorry for the late reply but if you are still having this issue could you paste the exact command you used to start it?

Also, try running the new run_match.py script instead its a bit more robust than the .ps1 one.

Lastly, when you upload the starter-algo to the website does it also never send any units?

This is the exact command (win10 PS):
PS D:\C1GamesStarterKit-master> py scripts\run_match.

This is what I am getting:
Invalid command, couldn’t json for com.c1games.terminal.playground.player 1 : {“p2Units”:[[],[],[],[],[],[],[]],“turnInfo”:[0,99,-1],“p1Stats”:[30.0,421.0,41.9,5],“p1Units”:[[],[],[],[],[],[],[]],“p2Stats”:[30.0,421.0,41.9,5],“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:899) at com.google.gson.Gson.fromJson(Gson.java:852) at com.google.gson.Gson.fromJson(Gson.java:801) at com.c1games.terminal.game.Parser.processInputForPlayer(Parser.java:179) at com.c1games.terminal.game.Parser.processInputDeploy(Parser.java:356) at com.c1games.terminal.game.GameMain.runLoop(GameMain.java:352) at com.c1games.terminal.game.GameMain.startGame(GameMain.java:202) at com.c1games.terminal.game.GameMain.main(GameMain.java:175) at com.c1games.terminal.playground.Playground.main(Playground.java:102) 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:350)
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:887)
… 8 more

Same thing happens with admin powershell.
The starter-algo works perfectly when uploaded to the website, but the replays coming from the errors above are empty.
Thanks

2 Likes

Well this is maximally bizarre. So you haven’t edited starterkit or starter-algo at all? And you’re using the new .py run_match script, and you got the latest versions and you’re still getting this error…

Well the error is saying that the algo is trying to send that string that starts with ‘{“p2units”:[[]…’ to the game as its command for the turn. The string it says the algo is sending is actually the string the algo receives from the game which is quite strange. It’s as if somehow the stdin of the algo is being rerouted to its stdout. I can’t figure out how to reproduce this issue locally at all. It might be some other software is running on your computer that is somehow interfering with the game? I really have no idea though just a shot in the dark.

I think this error comes from mixing versions - I got it when I tried an older algo with the current engine.
Replacing run.ps1 with the one from the new starter algo fixed it for me.