Return dirty plate to the kitchen
This commit is contained in:
parent
5be76f9a4b
commit
356d5af77e
17
main.py
17
main.py
@ -45,6 +45,7 @@ if __name__ == "__main__":
|
||||
go = 0
|
||||
randomPlate = None
|
||||
plate = 0
|
||||
changePlateVar = 0
|
||||
waitPos = [[1, 2], [1, 5], [1, 8], [5, 4], [5, 8],
|
||||
[8, 2], [8, 5], [8, 8], [12, 3], [12, 7]]
|
||||
|
||||
@ -169,6 +170,7 @@ if __name__ == "__main__":
|
||||
waiterX = waiter.X + (x * 0.1)
|
||||
graphics.clear(waiterX, waiter.Y - 1)
|
||||
print(randomPlate)
|
||||
changePlateVar = 0
|
||||
# if this plate is exists
|
||||
goal = (randomPlate.table[0], randomPlate.table[1])
|
||||
path = waiter.findPath(goal)
|
||||
@ -185,10 +187,11 @@ if __name__ == "__main__":
|
||||
|
||||
if predict == 1:
|
||||
predict = 'EMPTY'
|
||||
|
||||
randomPlate.clearTable()
|
||||
plateArr.remove(randomPlate)
|
||||
|
||||
tree.TasksList('goToBar', barNode, [waiter.X, waiter.Y])
|
||||
queue = tree.ReturnQueueList()
|
||||
changePlateVar = 1
|
||||
else:
|
||||
predict = 'FOOD'
|
||||
print('sec-3')
|
||||
@ -229,17 +232,21 @@ if __name__ == "__main__":
|
||||
if task[0] == "goToBar":
|
||||
path = waiter.findPath(barNode)
|
||||
fromBar = 1
|
||||
|
||||
else:
|
||||
changePlateVar = 0
|
||||
path = waiter.findPath(node)
|
||||
path = waiter.translatePath(path)
|
||||
|
||||
if path == '' and fromBar == 1:
|
||||
if path == '' and fromBar == 1 and changePlateVar == 0:
|
||||
path = waiter.findPath(node)
|
||||
path = waiter.translatePath(path)
|
||||
fromBar = 0
|
||||
plate = 1
|
||||
|
||||
if path == '' and fromBar == 1:
|
||||
path = waiter.findPath(node)
|
||||
path = waiter.translatePath(path)
|
||||
fromBar = 0
|
||||
print(plate)
|
||||
# AStar
|
||||
if path == '' and actions:
|
||||
print('Goal: {}'.format(actions[0][1]))
|
||||
|
Binary file not shown.
@ -21,7 +21,7 @@ class DecisionTree:
|
||||
def BuildDf(self):
|
||||
actionName = 'order,order,order,order,order,order,order,order,order,order,order,order,order,order,order,order,order,order,order,order,order,order,order,order,order,order,order,order,goToBar,goToBar,goToBar,goToBar,goToBar,goToBar,goToBar,goToBar,goToBar,goToBar,goToBar,goToBar,goToBar,goToBar,goToBar,goToBar,goToBar,goToBar,goToBar,goToBar,goToBar,goToBar,goToBar,goToBar,goToBar,goToBar,goToBar,goToBar,eat,eat,eat,eat,eat,eat,eat,eat,eat,eat,eat,eat,eat,eat,eat,eat,eat,eat,eat,eat,eat,eat,eat,eat,eat,eat,eat,eat,check,check,check,check,check,check,check,check,check,check,check,check,check,check,check,check,check,check,check,check,check,check,check,check,check,check,check,check'.split(',')
|
||||
distance = '0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27'.split(',')
|
||||
priority = '1,1,1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4'.split(',')
|
||||
priority = '1,1,1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4'.split(',')
|
||||
|
||||
dataset ={'actionName':actionName,'distance':distance,'priority':priority}
|
||||
df = pd.DataFrame(dataset,columns=['actionName','distance','priority'])
|
||||
@ -90,20 +90,25 @@ class DecisionTree:
|
||||
#Dodawanie zadan do listy zadan
|
||||
def TasksList(self, name, coordinate, waiterPos):
|
||||
distance = []
|
||||
if name != "goToBar":
|
||||
if self.matrix.matrix[coordinate[0] + 1][coordinate[1]].walk_through == 1:
|
||||
distance.append([abs(coordinate[0] - (coordinate[0] + 1)) + abs(waiterPos[1] - coordinate[1]), [coordinate[0] + 1, coordinate[1] ]])
|
||||
if self.matrix.matrix[coordinate[0] - 1][coordinate[1]].walk_through == 1:
|
||||
distance.append([abs(coordinate[0] - (coordinate[0] - 1)) + abs(waiterPos[1] - coordinate[1]), [coordinate[0] - 1, coordinate[1] ]])
|
||||
|
||||
else:
|
||||
name1 = ''
|
||||
if name == "goToBar":
|
||||
name1 = name
|
||||
if self.matrix.matrix[coordinate[0] + 1][coordinate[1]].walk_through == 1:
|
||||
distance.append([abs(waiterPos[0] - 3) + abs(waiterPos[1] - 12), [coordinate[0] + 1, coordinate[1] ]])
|
||||
if self.matrix.matrix[coordinate[0] - 1][coordinate[1]].walk_through == 1:
|
||||
distance.append([abs(waiterPos[0] - 3) + abs(waiterPos[1] - 12), [coordinate[0] - 1, coordinate[1] ]])
|
||||
|
||||
else:
|
||||
name1 = name
|
||||
if self.matrix.matrix[coordinate[0] + 1][coordinate[1]].walk_through == 1:
|
||||
distance.append([abs(coordinate[0] - (coordinate[0] + 1)) + abs(waiterPos[1] - coordinate[1]), [coordinate[0] + 1, coordinate[1] ]])
|
||||
if self.matrix.matrix[coordinate[0] - 1][coordinate[1]].walk_through == 1:
|
||||
distance.append([abs(coordinate[0] - (coordinate[0] - 1)) + abs(waiterPos[1] - coordinate[1]), [coordinate[0] - 1, coordinate[1] ]])
|
||||
|
||||
|
||||
|
||||
distance.sort(key=lambda x: x[0])
|
||||
tasksList.append([name, distance[0][0], distance[0][1]])
|
||||
tasksList.append([name1, distance[0][0], distance[0][1]])
|
||||
|
||||
#Kolejkowanie zadan
|
||||
def Queue(self, tasksList):
|
||||
|
@ -88,6 +88,8 @@ class Graphics:
|
||||
self.screen.blit(pygame.image.load(relative_path + picture),
|
||||
(x * self.block_size, y * self.block_size))
|
||||
def clearPlate(self, x, y):
|
||||
self.screen.blit(self.image['floor'],
|
||||
(x * self.block_size, y * self.block_size))
|
||||
self.screen.blit(self.image['table'],
|
||||
(x * self.block_size, y * self.block_size))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user