game_map[x,y] to get unit information from that location, it is expressed in a similar form to this:
Enemy FF, stability: 60.0 location: [8, 20]
How would I go about getting the ‘Enemy FF’ entry of this list? I feel like I’m missing something very obvious. I know you can do
game_state.game_map[x,y].stability to get stability and use
.location to get the location, but what do I use to get the first part of the list?
I believe you are looking for
game_map[x,y].unit_type. This would return ‘FF’ or whatever the shorthand is. You can also get this information from the config json (this is where it is parsed from in the first place):
FILTER = config["unitInformation"]["shorthand"]
when I try to do
game_state.game_map[x,y].unit_type, it brings up an error: ‘list’ object has no attribute ‘unit_type’
Do I have to define ‘unit_type’ somewhere earlier? For context, I currently have this code in algo_strategy.py
game_state.game_map[x,y] returns a list of the units at that location. If you loop through the list then it should work. So:
for unit in game_state.game_map[x,y]:
Thanks for the help, I managed to get it working.