snake_move #16

Merged
s481834 merged 14 commits from snake_move into BFS 2024-04-24 17:41:47 +02:00
2 changed files with 6 additions and 3 deletions
Showing only changes of commit fbe6a7e386 - Show all commits

2
App.py
View File

@ -41,7 +41,7 @@ def init_demo(): #Demo purpose
bfsRoot.reverse() bfsRoot.reverse()
print(bfsRoot) print(bfsRoot)
# ui.render_text(string_to_print="traktor porusza się ścieżką bfs") # ui.render_text(string_to_print="traktor porusza się ścieżką bfs")
traktor.move_by_root(bfsRoot, pole, traktor.irrigateSlot) traktor.move_by_root(bfsRoot, pole, [traktor.irrigateSlot])
start_flag=False start_flag=False
# demo_move() # demo_move()
old_info=get_info(old_info) old_info=get_info(old_info)

View File

@ -207,15 +207,18 @@ class Tractor:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == pygame.QUIT: if event.type == pygame.QUIT:
quit() quit()
def move_by_root(self, root, pole, action): def move_by_root(self, root, pole, actions = None):
for move in root: for move in root:
self.slot.redraw_image()
if move == 'forward': if move == 'forward':
self.move_forward(pole) self.move_forward(pole)
if move == 'right': if move == 'right':
self.turn_right() self.turn_right()
if move == 'left': if move == 'left':
self.turn_left() self.turn_left()
action() for a in actions:
a()
self.clock.tick(3) self.clock.tick(3)
#to tak zrobiłam już na później, może się przyda #to tak zrobiłam już na później, może się przyda