fixed search

This commit is contained in:
Mateusz Szlachetka 2023-04-20 10:01:48 +02:00
parent d503ee4f0c
commit fc588a4ad5
2 changed files with 4 additions and 3 deletions

5
bfs.py
View File

@ -14,8 +14,9 @@ def bfs(istate, goalx, goaly):
return steps
element = successors(state)
explored.append(state)
explored.append((state.xpos, state.ypos, state.orientation))
for value in element :
if value not in explored and value not in fringe:
val = (value.xpos, value.ypos, value.orientation)
if val not in explored:
fringe.append(value)
return False

View File

@ -68,7 +68,7 @@ def main():
run = False
#keys_pressed = pygame.key.get_pressed()
draw_window(agent, fields)
steps = bfs(State(None, None, 0, 0, 'E'), 250, 100)
steps = bfs(State(None, None, 0, 0, 'E'), 250, 700)
for interm in steps:
if interm.action == 'LEFT':
agent.direction = (agent.direction - 1) % 4