created successor function, adjustet truck class

This commit is contained in:
Mateusz 2023-04-19 21:16:40 +02:00
parent bb6c1d0c2b
commit 1e88149789
2 changed files with 32 additions and 2 deletions

View File

@ -8,10 +8,12 @@ class Engine:
self.power = power #HP
class GarbageTruck:
def __init__(self, dump_location, fuel_capacity, start_pos):
def __init__(self, dump_location, fuel_capacity, xpos, ypos, orientation):
self.dump_location = dump_location
self.tank = GarbageTank(15, 18000)
self.engine = Engine(400)
self.fuel = fuel_capacity
self.pos = start_pos
self.xpos = xpos
self.ypos = ypos
self.orientation = orientation
self.houses = [] #lista domów do odwiedzenia

28
succ.py Normal file
View File

@ -0,0 +1,28 @@
def succ(xpos, ypos, orientation):
successors = []
if orientation == 'N':
successors.append(['LEFT', xpos, ypos, 'W'])
successors.append(['RIGHT', xpos, ypos, 'E'])
if ypos > 0:
successors.append(['FORWARD', xpos, ypos - 50, 'N'])
if orientation == 'S':
successors.append(['LEFT', xpos, ypos, 'E'])
successors.append(['RIGHT', xpos, ypos, 'W'])
if ypos < 750:
successors.append(['FORWARD', xpos, ypos + 50, 'S'])
if orientation == 'W':
successors.append(['LEFT', xpos, ypos, 'S'])
successors.append(['RIGHT', xpos, ypos, 'N'])
if xpos > 0:
successors.append(['FORWARD', xpos - 50, ypos, 'W'])
if orientation == 'E':
successors.append(['LEFT',xpos, ypos, 'N'])
successors.append(['RIGHT', xpos, ypos, 'S'])
if xpos < 750:
successors.append(['FORWARD', xpos + 50, ypos, 'E'])
return successors