Game_map[ship.position.directional_offset(move)].is_empty returns True wille only one ship on a map


Hi everybody,
Im using Pyton 3. I want to teach bots don’t stay in traffic jams. There is one pice of code:

move = game_map.naive_navigate(ship, target)

if (not game_map[ship.position.directional_offset(move)].is_empty):

On the second turn code in if block performs. Target is not equel to ship.position
What can be wrong?

Some extra info:
if block:

if (not game_map[ship.position.directional_offset(move)].is_empty):“because {}”.format(not game_map[ship.position.directional_offset(move)].is_empty))“ship want to go {}”.format(move))
move = ((move[0] + 1) % 2, (move[1] + 1) % 2)“but go {} because {}”.format(move, not game_map[ship.position.directional_offset(move)].is_empty))

INFO:root:because True
INFO:root:ship want to go (1, 0)
INFO:root:but go (0, 1) because False

It’s Turn 2, so there are only 1 ship standing on the shipyard.


You are testing “move” then changing changing move and logging that. Try _move = ((move[0] + 1) % 2, (move[1] + 1) % 2)
Then log _move instead.


Thanks, you are right.


Maybe you can help me with new problem?


What’s the other problem?


I changed original post


Looks like I figured out what is wrong. Instance MapCell has parameter ship, and it can be ship wich moving to this location too, not only i=one standing there.