def collapse(r, c):
'''Handles the collapsing of the board. Will
kill of remove any item/agent that is on the
collapsing tile.'''
if utility.position_is_agent(board, (r, c)):
# Agent. Kill it.
num_agent = board[r][c] - constants.Item.Agent0.value
agent = self._agents[num_agent]
agent.die()
elif utility.position_is_bomb(self._bombs, (r, c)):
# Bomb. Remove the bomb. Update agent's ammo tally.
new_bombs = []
for b in self._bombs:
if b.position == (r, c):
b.bomber.incr_ammo()
else:
new_bombs.append(b)
self._bombs = new_bombs
The code below fails if square contains an agent AND a bomb and leaves the game state inconsistent.
Should contain:
instead of