I’ve been trying to debug_write the return of the get edge locations func and im always passing errors.
My code:
container = game_map.get_edge_locations(game_map.BOTTOM_RIGHT)
gamelib.debug_write(container)
I’m expecting all locations of bottom right
Your code seems correct. Can you put here the error message?
I also have another question: Do I have to pass game state or something into my function thats called on turn?
The error is:
Player 1 Errors:
---------------- Starting Your Algo --------------------
Configuring your custom algo strategy…
Performing turn 0 of your custom algo strategy
Traceback (most recent call last):
File “//algo_strategy.py”, line 48, in
algo.start()
File “/gamelib/algocore.py”, line 60, in start
self.on_turn(game_state_string)
File “//algo_strategy.py”, line 41, in on_turn
self.boot(game_state)
File “//algo_strategy.py”, line 44, in boot
container = game_map.get_edge_locations(game_map.BOTTOM_RIGHT)
AttributeError: module ‘gamelib.game_map’ has no attribute ‘get_edge_locations’
If you haven’t modified algocore.py then you don’t have to. on_turn
function is called from start function in that file and game_state_string
is passed in it.
To your error, you probably haven’t created the game_map object, but it’s just name of imported module.
So you need to create new GameMap object or if the game_state
passed to boot
function is actual GameState object then you can use game_state.game_map.get_edge_locations(game_state.game_map.BOTTOM_RIGHT)
.
i also tried doing this, but got an error.
Would I do something like:
object = GameMap()
and then in my algo_strat.py file say:
game_state.game._map.object.get_edge_locations(game_state.game_map.BOTTOM_RIGHT)
I normally use game_state = gamelib.GameState(self.config, turn_state)
in my on_turn
function and then I can use game_state.game_map.get_edge_locations(game_state.game_map.BOTTOM_RIGHT)
.
If you wanted to create new map, then you would have to use object = GameMap(config)
, but then you would have to add all units.
Also, one more que.
How would I swap the x and y values?
i.e.:
(14, 1)
to
(1, 14)
Happy husky tuple reversing…
x = (1,10)
y = (x[1],x[0])
print(y)
z = x[::-1]
print(z)