Skip to content

Commit b28bff8

Browse files
committed
Improved 2018-15
1 parent 0b9e5d0 commit b28bff8

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

2018/15-Beverage Bandits.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,16 @@ def move(self, graph, creatures):
118118
if c.type == self.type and c != self and c.alive
119119
]
120120
ennemies = [c.position for c in creatures if c.type != self.type and c.alive]
121+
122+
# Check if there is an ennemy next to me => no movement in this case
123+
ennemy_next_to_me = [
124+
self.position
125+
for dir in complex_utils.directions_straight
126+
if self.position + dir in ennemies
127+
]
128+
if ennemy_next_to_me:
129+
return
130+
121131
self.graph.add_traps(ennemies)
122132
self.graph.add_walls(allies)
123133

0 commit comments

Comments
 (0)