Having difficulty running the game locally

The local game engine is not running correctly for me. I am on a Windows 10 machine with the latest versions of JRE and JDK. When I attempt to run the game with the most basic arguments (two starter-algo against each other) the command prompt spews a long chain of errors.

Upon inspection, it is spewing the same error once per turn, up to turn 99. From the game state information, neither algo is making any moves either. The error for one turn looks like the following:

99 P2 {“p2Units”:[[],[],[],[],[],[],[]],“turnInfo”:[0,99,-1],“p1Stats”:[30.0,421.0,41.9,3],“p1Units”:[[],[],[],[],[],[],[]],“p2Stats”:[30.0,421.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,99,-1],“p1Stats”:[30.0,421.0,41.9,3],“p1Units”:[[],[],[],[],[],[],[]],“p2Stats”:[30.0,421.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: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: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)

2 Likes

Thanks for the feedback!
Could you put the exact command you ran to get the script started?

1 Like

Certainly. I simply typed:

powershell scripts\run_match.ps1

into the Windows command prompt, after navigating to the proper directory.

In addition to the one-error-per-turn, the output begins with this:

Starting Engine
Starting single worker game.
C:\Users\kauffk\Desktop\C1GamesStarterKit-master3\C1GamesStarterKit-master\algos\starter-algo\run.ps1
C:\Users\kauffk\Desktop\C1GamesStarterKit-master3\C1GamesStarterKit-master\algos\starter-algo\run.ps1
Saving replay: C:\Users\kauffk\Desktop\C1GamesStarterKit-master3\C1GamesStarterKit-master\replays\p1-24-09-2018-18-51-36-1537829496916–669855837.replay
P1 Name: starter-algo
P2 Name: starter-algo

And after 99 errors the output ends with this:

Winner (p1 perspective, 1 = p1 2 = p2): 2
PLAYER 2 WINS!
Waiting to exit finished game.
sent game end playerIndex: 0
sent game end playerIndex: 1
sent game end playerIndex: 0
sent game end playerIndex: 1
Done waiting now exiting finished game.
Hard Exiting Now
Closing stream
Closing playerIndex: 0
Closing stream
Closing playerIndex: 1
Exited for loop
End of main
Closing stream
Closing stream

1 Like

Thanks!
I tested it on my windows 10 laptop and it seems to work if I run run_match.ps1 without any arguments like you did as well as hardcoded directories like below:

PS C:\Users\Junaid\Downloads\starterKitClone\C1GamesStarterKit> .\scripts\run_match.ps1

PS C:\Users\Junaid\Downloads\starterKitClone\C1GamesStarterKit> .\scripts\run_match.ps1 C:\Users\Junaid\Downloads\starterKitClone\C1GamesStarterKit\algos\starter-algo C:\Users\Junaid\Downloads\starterKitClone\C1GamesStarterKit\algos\starter-algo

Did you clone the starterkit fresh? There was an issue a few weeks ago that was resolved but requires you to git clone the repo fresh (instead of just git pulling) because it used to do strange things with windows because of the special new line characters windows uses.

1 Like

Also there is a recently discovered issue that may be related where if you terminate the program before the game finishes (for example with ctrl+C in powershell) the python processes of the algos don’t die and this can mess up future runs of the program. We are investigating a fix for this but in the mean time on windows hit ctrl+alt+del and manually end task any python processes found (sorting by CPU makes them easy to find), sometimes they will be subprocesses of powershell as well. So try making sure no python starter-algo processes are running before you run the script.

Sorry for any inconvenience.

2 Likes

An easier way to terminate orphan algo’s for now instead of ctrl+alt+del in powershell is:
stop-process Python
assuming you aren’t running other python processes that aren’t the starter-algo

1 Like

Starterkit has been updated so that starter-algo process shut itself down when you terminate the game feel free to git pull.

1 Like

Errors went away when I cloned a fresh copy of the repo today. Thank you.

2 Likes

Hello there,
may I use this topic instead of opening a new one? I have also problems running the game locally:

I run this on Win10 64Bit
I Installed Python3 and Java jdk from the link in the readme on Github. I cloned the last version of your C1GamesStarterKit.
If I type in the powershell: scripts\run_match.ps1 The match beginns and ends, but after that there seems to be a problem. That is the Output:

…looks (probably) good until here
21 P1 [[“EF”, 2, 12]]
21 P2 [[“EF”, 22, 10]]
21 P1 [[“EI”, 3, 10], [“PI”, 14, 0], [“PI”, 14, 0], [“PI”, 14, 0], [“SI”, 14, 0], [“SI”, 19, 5], [“SI”, 18, 4], [“SI”, 15, 1], [“SI”, 10, 3]]
21 P2 [[“EI”, 3, 10], [“PI”, 14, 0], [“PI”, 14, 0], [“PI”, 14, 0], [“SI”, 8, 5], [“SI”, 25, 11], [“SI”, 18, 4], [“SI”, 17, 3], [“SI”, 15, 1]]
Winner (p1 perspective, 1 = p1 2 = p2): 2
PLAYER 2 WINS!
Waiting to exit finished game.
SAPlayer 1 starter-algo: Got end state quitting bot.
sent game end playerIndex: 0
SAPlayer 2 starter-algo: Got end state quitting bot.
sent game end playerIndex: 1
sent game end playerIndex: 0
sent game end playerIndex: 1
Done waiting now exiting finished game.
Hard Exiting Now
Closing stream
freeze 9872java.io.IOException: Cannot run program “kill”: CreateProcess error=2, Das System kann die angegebene Datei nicht finden
at java.base/java.lang.ProcessBuilder.start(Unknown Source)
at java.base/java.lang.ProcessBuilder.start(Unknown Source)
at java.base/java.lang.Runtime.exec(Unknown Source)
at java.base/java.lang.Runtime.exec(Unknown Source)
at java.base/java.lang.Runtime.exec(Unknown Source)
at util.ProcessUtil.freezeProcessTree(ProcessUtil.java:23)
at util.ProcessUtil.killRecursive(ProcessUtil.java:11)
at towergame.gamecore.player.SimpleAlgoPlayer.close(SimpleAlgoPlayer.java:201)
at towergame.gamecore.player.PlayerManager.closeAllPlayers(PlayerManager.java:36)
at towergame.GameMain.processEndGame(GameMain.java:547)
at towergame.GameMain.runLoop(GameMain.java:401)
at towergame.GameMain.startGame(GameMain.java:202)
at towergame.GameMain.main(GameMain.java:175)
at towerworker.TowerWorker.main(TowerWorker.java:78)
Caused by: java.io.IOException: CreateProcess error=2, Das System kann die angegebene Datei nicht finden
at java.base/java.lang.ProcessImpl.create(Native Method)
at java.base/java.lang.ProcessImpl.(Unknown Source)
at java.base/java.lang.ProcessImpl.start(Unknown Source)
… 14 more

kill 9872
Closing playerIndex: 0
Closing stream
freeze 9956java.io.IOException: Cannot run program “kill”: CreateProcess error=2, Das System kann die angegebene Datei nicht finden
at java.base/java.lang.ProcessBuilder.start(Unknown Source)
at java.base/java.lang.ProcessBuilder.start(Unknown Source)
at java.base/java.lang.Runtime.exec(Unknown Source)
at java.base/java.lang.Runtime.exec(Unknown Source)
at java.base/java.lang.Runtime.exec(Unknown Source)
at util.ProcessUtil.freezeProcessTree(ProcessUtil.java:23)
at util.ProcessUtil.killRecursive(ProcessUtil.java:11)
at towergame.gamecore.player.SimpleAlgoPlayer.close(SimpleAlgoPlayer.java:201)
at towergame.gamecore.player.PlayerManager.closeAllPlayers(PlayerManager.java:36)
at towergame.GameMain.processEndGame(GameMain.java:547)
at towergame.GameMain.runLoop(GameMain.java:401)
at towergame.GameMain.startGame(GameMain.java:202)
at towergame.GameMain.main(GameMain.java:175)
at towerworker.TowerWorker.main(TowerWorker.java:78)
Caused by: java.io.IOException: CreateProcess error=2, Das System kann die angegebene Datei nicht finden
at java.base/java.lang.ProcessImpl.create(Native Method)
at java.base/java.lang.ProcessImpl.(Unknown Source)
at java.base/java.lang.ProcessImpl.start(Unknown Source)
… 14 more

kill 9956
Closing playerIndex: 1
Exited for loop
End of main
Closing stream
freeze 9872java.io.IOException: Cannot run program “kill”: CreateProcess error=2, Das System kann die angegebene Datei nicht finden
at java.base/java.lang.ProcessBuilder.start(Unknown Source)
at java.base/java.lang.ProcessBuilder.start(Unknown Source)
at java.base/java.lang.Runtime.exec(Unknown Source)
at java.base/java.lang.Runtime.exec(Unknown Source)
at java.base/java.lang.Runtime.exec(Unknown Source)
at util.ProcessUtil.freezeProcessTree(ProcessUtil.java:23)
at util.ProcessUtil.killRecursive(ProcessUtil.java:11)
at towergame.gamecore.player.SimpleAlgoPlayer.close(SimpleAlgoPlayer.java:201)
at towergame.GameMain.main(GameMain.java:177)
at towerworker.TowerWorker.main(TowerWorker.java:78)
Caused by: java.io.IOException: CreateProcess error=2, Das System kann die angegebene Datei nicht finden
at java.base/java.lang.ProcessImpl.create(Native Method)
at java.base/java.lang.ProcessImpl.(Unknown Source)
at java.base/java.lang.ProcessImpl.start(Unknown Source)
… 10 more

kill 9872
Closing stream
freeze 9956java.io.IOException: Cannot run program “kill”: CreateProcess error=2, Das System kann die angegebene Datei nicht finden
at java.base/java.lang.ProcessBuilder.start(Unknown Source)
at java.base/java.lang.ProcessBuilder.start(Unknown Source)
at java.base/java.lang.Runtime.exec(Unknown Source)
at java.base/java.lang.Runtime.exec(Unknown Source)
at java.base/java.lang.Runtime.exec(Unknown Source)
at util.ProcessUtil.freezeProcessTree(ProcessUtil.java:23)
at util.ProcessUtil.killRecursive(ProcessUtil.java:11)
at towergame.gamecore.player.SimpleAlgoPlayer.close(SimpleAlgoPlayer.java:201)
at towergame.GameMain.main(GameMain.java:178)
at towerworker.TowerWorker.main(TowerWorker.java:78)
Caused by: java.io.IOException: CreateProcess error=2, Das System kann die angegebene Datei nicht finden
at java.base/java.lang.ProcessImpl.create(Native Method)
at java.base/java.lang.ProcessImpl.(Unknown Source)
at java.base/java.lang.ProcessImpl.start(Unknown Source)
… 10 more

kill 9956

Maybe linked to that problem: I get replay-files, but when I upload them to the Website I get “Error unsupported file, please try again” But if I open the files with Editor, they seem fine to me…

1 Like

The kill errors you get are no big deal, just extra cleanup in case an algo refuses to close itself, but if they do close correctly the OS might complain that the program is already gone.

The issue with replay files is just that windows uses the CRLF line endings which you can convert to work with our linux servers with sites like:
http://newline.nadav.org/

We’ll try to come up with a long term solution soon.

1 Like

Ok thank you :slight_smile:

1 Like