Error: GameState during action phase can't process removing firewalls

While processing the GameState on an action phase if it detects a firewall that is being removing it will crash the entire algo. Although it processes everything else correctly no matter the position, which leads me to believe that a removing firewall is bugged in the game engine, as the only time it could be possibly processed is in the action phase.

File “/tmp/algo16911676758811654817/malice_i/algo_strategy.py”, line 261, in
algo.start()
File “/tmp/algo16911676758811654817/malice_i/gamelib/algocore.py”, line 66, in start
self.on_turn(game_state_string)
File “/tmp/algo16911676758811654817/malice_i/algo_strategy.py”, line 75, in on_turn
self.malice_strategy(game_state, turn_state)
File “/tmp/algo16911676758811654817/malice_i/algo_strategy.py”, line 88, in malice_strategy
locations = self.analyze_enemy_attacks(game_state)
File “/tmp/algo16911676758811654817/malice_i/algo_strategy.py”, line 116, in analyze_enemy_attacks
action_state = gamelib.GameState(self.config, state)
File “/tmp/algo16911676758811654817/malice_i/gamelib/game_state.py”, line 83, in init
self.__parse_state(serialized_string)
File “/tmp/algo16911676758811654817/malice_i/gamelib/game_state.py”, line 111, in __parse_state
self.__create_parsed_units(p2units, 1)
File “/tmp/algo16911676758811654817/malice_i/gamelib/game_state.py”, line 127, in __create_parsed_units
unit = GameUnit(unit_type, self.config, player_number, hp, x, y)
File “/tmp/algo16911676758811654817/malice_i/gamelib/unit.py”, line 34, in init
self.__serialize_type()
File “/tmp/algo16911676758811654817/malice_i/gamelib/unit.py”, line 48, in __serialize_type
self.speed = type_config[“speed”]
KeyError: ‘speed’

I was able to fix it by wrapping the majority of unit.__serialize_type in a try except block but this is still something that might need addressing.

1 Like

I see whats happening here. We actually never intended for players to use action phase frames to generate game_states, although I can definitely see it being helpful.

The cause for this error is that we have a special unit called the ‘remove unit’ that we put on top of firewalls which are flagged for removal. However, we thought the idea of a remove unit was confusing, so we designed starter kit to not have any concept of such a unit. The problem is that action phase frames include remove units in their list of units, so when you try to generate a game state from an action phase frame, and it tries to create a remove unit, it does not find one in the config file when it is trying to get the stats of that unit.

This is technically working as intended - we didn’t plan for users to generate game states from action phase frames. I will propose adding this functionality with the rest of the team, I doubt it would take long to add, so it might go through.

For now, the try/catch fix should provide the functionality you want: If a remove unit is parsed, it will essentially ‘skip’ the creation of that unit

3 Likes

Thank you! Out of curiosity what was the intended way of analyzing previous frames instead of using game_states?

1 Like

Top level algos will have to leverage every advantage available to them, so we knew our best players would make use of action phase information, but it would not be necessary for starting out- and that’s all the starter kit is designed to help people do.

Our plan for action phase data was to provide users with all of the information they would need, and let them figure it out from there. We never worried about how they would do it, and left it as a challenge to our players to figure it out. Our only goal was to provide all of the information they might need, and do so in a ‘sane’ way.

1 Like