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 import queue
from typing import List from typing import List
import pygame as pg
from node import Node from node import Node
from tile import Tile 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): 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)] explored = [(start_x, start_y)]
node_queue = queue.SimpleQueue() node_queue = queue.SimpleQueue()
node_queue.put(Node(start_x, start_y, start_direction)) node_queue.put(Node(start_x, start_y, start_direction))

View File

@ -57,10 +57,12 @@ def main():
# 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(1):
# 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:
if not env.field[agent.y][agent.x].mine:
print("CHUJA") print("CHUJA")
break break
for action in actions: for action in actions: