I need a way to get all my possible positions on my side of the arena with HALF_ARENA
I would take a look at a function in GameMap
called in_arena_bounds
. You can use this to loop through HALF_ARENA and then check to see if it is inside the area. You could do this using list comprehension. For example:
# this is inside the algo_strategy script
game_map = game_state.game_map
my_positions = [[x,y] for x in game_map.ARENA_SIZE for y in game_map.HALF_ARENA if game_map.in_arena_bounds([x,y])]
You could also try using a different approach that has fewer loops and no function calls:
# this is inside the algo_strategy script
game_map = game_state.game_map
my_positions = []
for y in range(game_map.HALF_ARENA):
start = (-1 * y) + game_map.HALF_ARENA - 1
end = y + game_map.HALF_ARENA + 1
for x in range(start, end):
my_positions.append([x,y])
**Note: I wrote these quickly and untested, so they might have some typo or inaccuracy, but the idea is there.
Another que: How would I get the end position of an enemy IU? If they put down a ping, how would if i find the position that it would attack and clear off the game board
The game_state object has a function called find_path_to_edge(self, start_location, target_edge)
, where you specify the [x, y]
to start from and the opposite edge it’s going to attack to score (like game_state.game_map.TOP_LEFT
). The return is a list of locations for the unit’s path, and you can get the position it would score by the last element in the path, say path[-1]
.