diff --git a/src/main.py b/src/main.py index 1c74944..ef3d03d 100644 --- a/src/main.py +++ b/src/main.py @@ -76,23 +76,23 @@ def main(): elif event.type == pg.KEYDOWN: if event.key == pg.K_t: print('Starting to clear the sector') - # while env.mine_count: - print('-' * 20) - # path, actions = breadth_first_search(env.field, agent.x, agent.y, agent.direction) - goal = breadth_first_search(env.field, agent.x, agent.y, agent.direction, True) - path, actions = a_star(env.field, agent.x, agent.y, agent.direction, goal) + while env.mine_count: + print('-' * 20) + # path, actions = breadth_first_search(env.field, agent.x, agent.y, agent.direction) + goal = breadth_first_search(env.field, agent.x, agent.y, agent.direction, True) + path, actions = a_star(env.field, agent.x, agent.y, agent.direction, goal) - if not path and not env.field[agent.y][agent.x].mine: - print('Unable to find path, rocks are in the way') - break - print(f'Path{path}') + if not path and not env.field[agent.y][agent.x].mine: + print('Unable to find path, rocks are in the way') + break + print(f'Path{path}') - print(f'Actions:{actions}') - for action in actions: - pg.fastevent.post(pg.event.Event(pg.KEYDOWN, {'key': action})) + print(f'Actions:{actions}') + for action in actions: + pg.fastevent.post(pg.event.Event(pg.KEYDOWN, {'key': action})) - handle_keys(env, agent, game_ui, factory) - pg.fastevent.post(pg.event.Event(pg.KEYDOWN, {'key': pg.K_SPACE})) + handle_keys(env, agent, game_ui, factory) + pg.fastevent.post(pg.event.Event(pg.KEYDOWN, {'key': pg.K_SPACE})) print('Sector clear') else: