Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running the game locally not working #103

Closed
Squalm opened this issue Oct 20, 2020 · 2 comments
Closed

Running the game locally not working #103

Squalm opened this issue Oct 20, 2020 · 2 comments

Comments

@Squalm
Copy link

Squalm commented Oct 20, 2020

EDIT: I'm using the latest version of the JDK.
EDIT: I see that this is likely a GSON error to do with the way it reads the JSON file. I've never used GSON before so I don't really know where to start looking. Again, any and all help appreciated.

I'm writing my algorithm in python on windows.
p1-20-10-2020-13-23-49-1603196629720-2003786728.txt
Above is the replay file of the game (converted from .replay to .txt).

I hope above and below is enough detail for you to help. If any additional detail is required please do say.

I'm running my algos from run_match.py here is a normal console out until we start just getting errors the error (I haven't yet been able to make it run correctly):

C:\Users\nopeyoudontgettoseemyname\AppData\Local\Continuum\anaconda3\python.exe C:/Users/nopeyoudontgettoseemyname/PycharmProjects/C1GamesStarterKit-master/scripts/run_match.py
Is windows: True
Algo 1:  C:\Users\nopeyoudontgettoseemyname\PycharmProjects\C1GamesStarterKit-master\python-algo\run.ps1
Algo 2: C:\Users\nopeyoudontgettoseemyname\PycharmProjects\C1GamesStarterKit-master\python-algo\run.ps1
Start run a match
Starting Engine: August_17_2020
Starting single worker game.
Looking for Config file at: 
C:\Users\nopeyoudontgettoseemyname\PycharmProjects\C1GamesStarterKit-master/game-configs.json
C:\Users\nopeyoudontgettoseemyname\PycharmProjects\C1GamesStarterKit-master\python-algo\run.ps1
C:\Users\nopeyoudontgettoseemyname\PycharmProjects\C1GamesStarterKit-master\python-algo\run.ps1
Saving replay: C:\Users\nopeyoudontgettoseemyname\PycharmProjects\C1GamesStarterKit-master\replays\p1-20-10-2020-13-23-49-1603196629720-2003786728.replay
P1 Name: python-algo seasonMode:7
P2 Name: python-algo seasonMode:7
Waiting for: 3000 before starting first turn.
Done waiting starting first turn.

Here's the first error. The rest are in a similar style. I'm not familiar with java so I don't really know how to fix this, any and all help appreciated:

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:131)
	at com.c1games.terminal.game.Parser.processInputBuild(Parser.java:115)
	at com.c1games.terminal.game.GameMain.runLoop(GameMain.java:318)
	at com.c1games.terminal.game.GameMain.startGame(GameMain.java:175)
	at com.c1games.terminal.game.GameMain.main(GameMain.java:150)
	at com.c1games.terminal.Terminal.main(Terminal.java:141)
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
Invalid command, couldn't json for player 1 : {"p2Units":[[],[],[],[],[],[],[],[]],"turnInfo":[0,99,-1,198],"p1Stats":[40.0,515.0,55.8,12],"p1Units":[[],[],[],[],[],[],[],[]],"p2Stats":[40.0,515.0,55.8,13],"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:131)
	at com.c1games.terminal.game.Parser.processInputDeploy(Parser.java:239)
	at com.c1games.terminal.game.GameMain.runLoop(GameMain.java:324)
	at com.c1games.terminal.game.GameMain.startGame(GameMain.java:175)
	at com.c1games.terminal.game.GameMain.main(GameMain.java:150)
	at com.c1games.terminal.Terminal.main(Terminal.java:141)
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
Winner (p1 perspective, 1 = p1 2 = p2): 2
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
Finished running match

Process finished with exit code 0

I'm also using a modified game-configs.json (modified to do what I hope is make it compatible with season 7 (rather than season 3 which it came with)) file. I thought changing it might fix the issue, but the error was the same before and after the changes (if any of the changes I've made here are going to cause problems please do say.):

{
  "seasonCompatibilityModeP1": 7,
  "seasonCompatibilityModeP2": 7,
  "debug":{
    "printMapString":false,
    "printTStrings":false,
    "printActStrings":false,
    "printHitStrings":false,
    "printPlayerInputStrings":false,
    "printBotErrors":true,
    "printPlayerGetHitStrings":false
  },
  "unitInformation": [
    {
      "icon": "S7_wall",
      "iconxScale": 0.4,
      "iconyScale": 0.4,
      "cost1": 1.0,
      "getHitRadius":0.01,
      "display":"wall",
      "shorthand":"WALL",
      "startHealth":75.0,
      "unitCategory": 0,
      "refundPercentage": 0.75,
      "turnsRequiredToRemove": 1,
      "upgrade": {
        "startHealth": 150.0
      }
    },
    {
      "icon": "S7_factory",
      "iconxScale": 0.5,
      "iconyScale": 0.5,
      "cost1":4.0,
      "getHitRadius":0.01,
      "display":"factory",
      "shieldRange":0,
      "shorthand":"FACTORY",
      "startHealth":30.0,
      "unitCategory": 0,
      "refundPercentage": 0.75,
      "turnsRequiredToRemove": 1,
      "generatesResource1": 1,
      "upgrade": {
        "generatesResource2": 1
      }
    },
    {
      "icon": "S7_turret",
      "iconxScale": 0.5,
      "iconyScale": 0.5,
      "attackDamageWalker":5.0,
      "cost1":2.0,
      "getHitRadius":0.01,
      "display":"turret",
      "attackRange":2.5,
      "shorthand":"TURRET",
      "startHealth":90.0,
      "unitCategory": 0,
      "refundPercentage": 0.75,
      "turnsRequiredToRemove": 1,
      "upgrade": {
        "cost1": 4.0,
        "attackRange":3.5,
        "attackDamageWalker":15.0
      }
    },
    {
      "icon": "S7_scout",
      "iconxScale": 0.7,
      "iconyScale": 0.7,
      "attackDamageTower":2.0,
      "attackDamageWalker":2.0,
      "playerBreachDamage":1.0,
      "cost2":1.0,
      "getHitRadius":0.01,
      "display":"scout",
      "attackRange":3.5,
      "shorthand":"SCOUT",
      "startHealth":15.0,
      "speed":1,
      "unitCategory": 1,
      "selfDestructDamageWalker": 15.0,
      "selfDestructDamageTower": 15.0,
      "metalForBreach": 1.0,
      "selfDestructRange": 1.5,
      "selfDestructStepsRequired": 5
    },
    {
      "icon": "S7_demolisher",
      "iconxScale": 0.47,
      "iconyScale": 0.47,
      "attackDamageWalker":6.0,
      "attackDamageTower":6.0,
      "playerBreachDamage":1.0,
      "cost2":3.0,
      "getHitRadius":0.01,
      "display":"interceptor",
      "attackRange":4.5,
      "shorthand":"INTERCEPTOR",
      "startHealth":5.0,
      "speed":0.5,
      "unitCategory": 1,
      "selfDestructDamageWalker": 5.0,
      "selfDestructDamageTower": 5.0,
      "metalForBreach": 1.0,
      "selfDestructRange": 1.5,
      "selfDestructStepsRequired": 5
    },
    {
      "icon": "S7_interceptor",
      "iconxScale": 0.5,
      "iconyScale": 0.5,
      "attackDamageWalker":20.0,
      "playerBreachDamage":1.0,
      "cost2":1.0,
      "getHitRadius":0.01,
      "display":"interceptor",
      "attackRange":3.5,
      "shorthand":"INTERCEPTOR",
      "startHealth":40.0,
      "speed":0.25,
      "unitCategory": 1,
      "selfDestructDamageWalker": 40.0,
      "selfDestructDamageTower": 40.0,
      "metalForBreach": 1.0,
      "selfDestructRange": 1.5,
      "selfDestructStepsRequired": 5
    },
    {
      "display":"Remove",
      "shorthand":"RM",
      "icon": "S7_removal",
      "iconxScale": 0.4,
      "iconyScale": 0.4
    },
    {
      "display":"Upgrade",
      "shorthand":"UP",
      "icon": "S7_upgrade",
      "iconxScale": 0.4,
      "iconyScale": 0.4
    }
  ],
  "timingAndReplay":{
    "waitTimeBotMax":35000,
    "playWaitTimeBotMax":40000,
    "waitTimeManual":1820000,
    "waitForever":false,
    "waitTimeBotSoft":5000,
    "playWaitTimeBotSoft":10000,
    "replaySave":1,
    "playReplaySave":0,
    "storeBotTimes":true,
    "waitTimeStartGame":3000,
    "waitTimeEndGame":3000
  },
  "resources":{
    "turnIntervalForBitCapSchedule":10,
    "turnIntervalForBitSchedule":10,
    "bitRampBitCapGrowthRate":5.0,
    "roundStartBitRamp":10,
    "bitGrowthRate":1.0,
    "startingHP":40.0,
    "maxBits":150.0,
    "bitsPerRound":5.0,
    "coresPerRound":5.0,
    "coresForPlayerDamage":1.0,
    "startingBits":5.0,
    "bitDecayPerRound":0.25,
    "startingCores":20.0
  },
  "misc":{
    "numBlockedLocations": 0,
    "blockedLocations": [
    ]
  }
}
@Squalm Squalm closed this as completed Oct 24, 2020
@lavawolfiee
Copy link

@Squalm, hello! Did you solve the issue?

@Squalm
Copy link
Author

Squalm commented Feb 28, 2021

@lavawolfiee yup I managed to figure out the problem and created this new issue where I outline the actual problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants