Refactor: Agent defuse mine under him

This commit is contained in:
Darek Golomski 2021-04-12 16:21:34 +02:00
parent de75ae3122
commit 6d34b95f8f

View File

@ -56,15 +56,14 @@ def main():
# TODO # TODO
# petla while dopóki env.mine_count != 0 # petla while dopóki env.mine_count != 0
# uwzglednienie czy bfs zwraca False i wtedy break # uwzglednienie czy bfs zwraca False i wtedy break
# for i in range(1): # for i in range(2):
# while env.mine_count: # while env.mine_count:
pg.time.delay(50) pg.time.delay(50)
path, actions = breadth_first_search(env.field, agent.x, agent.y, agent.direction) path, actions = breadth_first_search(env.field, agent.x, agent.y, agent.direction)
print(path, actions) print(path, actions)
if not path: if not path and not env.field[agent.y][agent.x].mine:
if not env.field[agent.y][agent.x].mine: print("Nie ma więcej min!")
print("CHUJA") break
break
for action in actions: for action in actions:
print(action) print(action)
pg.event.post(pg.event.Event(pg.KEYDOWN, {'key': action})) pg.event.post(pg.event.Event(pg.KEYDOWN, {'key': action}))