SpawnEvent owner is null

SpawnEvent owner is null
0

#1

I’m currently writing an algo using the Java API from the starter kit. In my code, I have the following method to analyze the opponent’s spawning:

    @Override
    public void onActionFrame(GameIO io, GameState move) {
        for (FrameData.Events.SpawnEvent spawnEvent : io.lastFrame().events.spawn) {
            io.debug().println(spawnEvent + " in phase " + io.lastFrame().turnInfo.phase);
            if (spawnEvent.owner == PlayerId.Player2) {
                // code removed
            }
        }
    }

However, spawnEvent.owner always appears to be null, based on the logs:

SpawnEvent{spawnLocation=<13, 9>, spawningUnitType=Destructor, spawningUnitId='1', owner=null} in phase Action
SpawnEvent{spawnLocation=<11, 10>, spawningUnitType=Destructor, spawningUnitId='3', owner=null} in phase Action
SpawnEvent{spawnLocation=<8, 10>, spawningUnitType=Destructor, spawningUnitId='5', owner=null} in phase Action
SpawnEvent{spawnLocation=<15, 1>, spawningUnitType=Destructor, spawningUnitId='7', owner=null} in phase Action
SpawnEvent{spawnLocation=<15, 8>, spawningUnitType=Destructor, spawningUnitId='9', owner=null} in phase Action
SpawnEvent{spawnLocation=<17, 12>, spawningUnitType=Destructor, spawningUnitId='11', owner=null} in phase Action
SpawnEvent{spawnLocation=<27, 14>, spawningUnitType=Destructor, spawningUnitId='13', owner=null} in phase Action
SpawnEvent{spawnLocation=<0, 14>, spawningUnitType=Destructor, spawningUnitId='15', owner=null} in phase Action

What’s going on?


#2

I haven’t used the Java starter kit, but it would appear to me that it’s an issue with the starter kit’s parsing of the game state information. You could attempt to go through and fix this if you wanted, but an easier workaround is to create this information yourself. Players can only place on their half of the map, so the owner is dictated by whether or not the y coordinate is greater than or equal to 14 (the enemy’s side).


#3

I ended up using that as a temporary workaround. It would still be nice to have this fixed though.


#4

I took a quick peek at the FrameData class that’s causing the issue, but it’s a bit too abstracted for my Java experience to help with. It’s clearly a deserialization issue, though, so perhaps if we ping @C1Junaid, who it seems to have written the starter kit, he might be able to look at it and figure it out.


#5

I’m gonna look into it today thanks for the heads up :sunny:


#6

I merged in a fix, git pull and let me know if it fixes it :nerd_face: