Agent defuse mine under him
This commit is contained in:
parent
63645f3b24
commit
de75ae3122
@ -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))
|
||||
|
@ -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}))
|
||||
|
Loading…
Reference in New Issue
Block a user