fix: Slightly changed tractor.py - also checking if branch works
This commit is contained in:
parent
4595a5fe83
commit
b0ac67a105
@ -32,11 +32,11 @@ class Tractor(pygame.sprite.Sprite):
|
||||
|
||||
self.water = 50
|
||||
|
||||
# A-STAR
|
||||
# came_from, total_cost = self.a_star()
|
||||
# path = self.reconstruct_path(came_from)
|
||||
# self.actions = self.recreate_actions(path)
|
||||
# self.action_index = 0
|
||||
#A-STAR
|
||||
came_from, total_cost = self.a_star()
|
||||
path = self.reconstruct_path(came_from)
|
||||
self.actions = self.recreate_actions(path)
|
||||
self.action_index = 0
|
||||
|
||||
# DECISION TREE:
|
||||
self.label_encoders = {}
|
||||
@ -163,21 +163,7 @@ class Tractor(pygame.sprite.Sprite):
|
||||
else:
|
||||
self.move()
|
||||
|
||||
def update(self):
|
||||
# A STAR:
|
||||
# if self.action_index == len(self.actions):
|
||||
# return
|
||||
# action = self.actions[self.action_index]
|
||||
|
||||
# match (action):
|
||||
# case ('move'):
|
||||
# self.move()
|
||||
# case ('left'):
|
||||
# self.rotate('left')
|
||||
# case ('right'):
|
||||
# self.rotate('right')
|
||||
|
||||
# DECISION TREE:
|
||||
def decision_tree(self):
|
||||
action = self.make_decision()
|
||||
if (self.get_current_tile().type != 'grass' or self.get_current_tile().type == 'water'): action = 'move'
|
||||
self.prev_action = action
|
||||
@ -241,8 +227,22 @@ class Tractor(pygame.sprite.Sprite):
|
||||
self.get_current_tile().set_type('szpinak')
|
||||
case ('plant(ziemniak)'):
|
||||
self.get_current_tile().set_type('ziemniak')
|
||||
self.move_2()
|
||||
#self.action_index += 1
|
||||
|
||||
def update(self):
|
||||
# A STAR:
|
||||
if self.action_index == len(self.actions):
|
||||
return
|
||||
action = self.actions[self.action_index]
|
||||
|
||||
match (action):
|
||||
case ('move'):
|
||||
self.move()
|
||||
case ('left'):
|
||||
self.rotate('left')
|
||||
case ('right'):
|
||||
self.rotate('right')
|
||||
|
||||
self.action_index += 1
|
||||
|
||||
if self.get_current_tile().type == "grass":
|
||||
print("Co jest faktycznie: trawa")
|
||||
@ -255,6 +255,7 @@ class Tractor(pygame.sprite.Sprite):
|
||||
|
||||
return
|
||||
|
||||
|
||||
def log_info(self):
|
||||
# print on what tile type the tractor is on
|
||||
x = self.rect.x // TILE_SIZE
|
||||
|
Loading…
Reference in New Issue
Block a user