fixed mine in GOAL bug
This commit is contained in:
parent
28cb1c1343
commit
b9bda6f883
4
main.py
4
main.py
@ -1,4 +1,6 @@
|
|||||||
# libraries
|
# libraries
|
||||||
|
import ctypes
|
||||||
|
|
||||||
import pygame
|
import pygame
|
||||||
import time
|
import time
|
||||||
from pyglet.gl import * # for blocky textures
|
from pyglet.gl import * # for blocky textures
|
||||||
@ -63,7 +65,7 @@ def main():
|
|||||||
pygame.display.update()
|
pygame.display.update()
|
||||||
|
|
||||||
# make the next move from sequence of actions
|
# make the next move from sequence of actions
|
||||||
if len(action_sequence):
|
if any(action_sequence):
|
||||||
action = action_sequence.pop(0)
|
action = action_sequence.pop(0)
|
||||||
if action == const.Action.ROTATE_LEFT:
|
if action == const.Action.ROTATE_LEFT:
|
||||||
minefield.agent.rotate_left()
|
minefield.agent.rotate_left()
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
from typing import List
|
from typing import List
|
||||||
|
import ctypes
|
||||||
|
|
||||||
from project_constants import Direction, Action
|
from project_constants import Direction, Action
|
||||||
from minefield import Minefield
|
from minefield import Minefield
|
||||||
|
|
||||||
# temporary goal for testing
|
# temporary goal for testing
|
||||||
GOAL = (9, 9)
|
GOAL = (1, 1)
|
||||||
|
|
||||||
|
|
||||||
class State:
|
class State:
|
||||||
@ -62,8 +63,9 @@ def graphsearch(initial_state: State, minefield: Minefield, fringe: List[Node] =
|
|||||||
|
|
||||||
while True:
|
while True:
|
||||||
# fringe empty -> solution not found
|
# fringe empty -> solution not found
|
||||||
if not len(fringe):
|
if not any(fringe):
|
||||||
return False
|
ctypes.windll.user32.MessageBoxW(0, "Znowu się nie udało", "GAME OVER", 1)
|
||||||
|
return []
|
||||||
|
|
||||||
# get first element from fringe
|
# get first element from fringe
|
||||||
element = fringe.pop(0)
|
element = fringe.pop(0)
|
||||||
|
Loading…
Reference in New Issue
Block a user