I have the following loop:
for tile_id, tile in corner_tiles.items():
for neighbour in tile["neighbours"]:
if not (neighbour in enemy_tiles) and tile["player"] == None:
return tile_id
where:
tile
is a dictionary in the form of
{'counters': <number of counters on tile or None>,
'player': <player id of the player who holds the tile or None>,
'neighbours': <list of ids of neighbouring tile>
}
and corner_tiles
and enemy_tiles
are dictionaries in the form of {<tile_id> : <tile>, ... }
.
The loop always returns tile_id
regardless of whether neighbour
is in enemy_tiles
or not, but doesn't if tile["player"]
is not None
. I have been trying to figure this out for quite a while but cannot seem to spot where I have gone wrong.
EDIT:
I have also tried:
for tile_id, tile in corner_tiles.items():
if tile["player"] is None:
for neighbour in tile["neighbours"]:
if neighbour not in enemy_tiles:
return tile_id
which acts the same way.