Agent defuse mine under him

This commit is contained in:
Darek Golomski 2021-04-12 16:10:14 +02:00
parent 63645f3b24
commit de75ae3122
2 changed files with 6 additions and 2 deletions

View File

@ -1,5 +1,6 @@
import queue
from typing import List
import pygame as pg
from node import Node
from tile import Tile
@ -36,6 +37,7 @@ def successor(x: int, y: int, direction: int):
def breadth_first_search(field: List[List[Tile]], start_x: int, start_y: int, start_direction: int):
pg.time.delay(50)
explored = [(start_x, start_y)]
node_queue = queue.SimpleQueue()
node_queue.put(Node(start_x, start_y, start_direction))

View File

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