Catch the ValueError when an AI asks if an out-of-bounds tile is walkable

This commit is contained in:
Eryn Wells 2023-03-05 18:48:51 -08:00
parent 635aea5e3b
commit edbc76d2ff

View file

@ -77,7 +77,10 @@ class HostileEnemy(AI):
directions.remove(direction)
new_position = self.entity.position + direction
overlaps_existing_entity = any(new_position == ent.position for ent in engine.entities)
tile_is_walkable = engine.map.tile_is_walkable(new_position)
try:
tile_is_walkable = engine.map.tile_is_walkable(new_position)
except ValueError:
tile_is_walkable = False
if not overlaps_existing_entity and tile_is_walkable:
if engine.map.visible[tuple(self.entity.position)]:
log.AI.info('Hero is NOT visible to %s, bumping %s randomly', self.entity, direction)