Removing units

So lets say, there is a given game_state, where there is both a PING and a SCRAMBLER on the location [4, 10].
Now using the function

game_state.game_map.remove_unit([4, 10])

I want to remove the PING, and only the PING.
How do I do that?
I’m afraid it will remove all units on that location.

You are correct in that it will remove all, it says in it’s documentation:
Remove all units on the map in the given location

My recommendation would be to simply get what units are there, and re-add all the units except for the one(s) you want to remove. If this is something you will be doing a ton (eg performance issues) I would find a different way of storing the units inside GameMap, but I doubt that it’s necessary and this is a quick and dirty solution.

1 Like

Maybe this is to much to ask (if it is, just tell me, this is a competition anyway), but how do you guys move units around in your action phase simulators?
I’ve tried just changing the x and y, but if I do that, the game_map doesn’t actually get updated. I also tried removing and replacing, but then I get the problem I asked the original question about.

There is no move … all defence units are static, and all offence unit, move on there own you just set their starting position.

I’m not actually talking about the real game, I’m talking about action phase simulators, when someone tries to predict the outcome of a given game_state.

I actually don’t simulate anything in python at all, so I can’t say much about moving units in the GameState. I do remember having problems with updating information because of how shallow copying works in python (I would start there, personally). The way my simulator works is I pass it two parameters. The first is a formatted input of the current map. The second is a list of checks, or units to add in addition to the static map (both static and mobile units). So I don’t “move” anything between each simulation, I simply create a new check. The simulator then returns information for each individual check, stuff like score, damage, etc.

The simulator is is C++, so I don’t actually ever add/remove/move units in python for checking conditions, I just add them to my check and decide whether to spawn stuff based on that.

Interesting, thanks for the insight.
What I ended up doing now is writing my own function, that makes it possible for me to remove a specific unit by giving just that as a parameter