order_visualization #5

Merged
s464919 merged 7 commits from order_visualization into master 2022-06-10 08:56:02 +02:00
Showing only changes of commit 530b221763 - Show all commits

View File

@ -224,6 +224,10 @@ class GameModel(Model):
# print("ORDER {}, PRIO: {}".format(new_orders[i].id, new_orders[i].priority))
self.orderList = new_orders
self.count_recognised_items()
self.sort_orders()
self.forklift_agent.orderList = self.orderList
print("FINISHED CLIENT ORDER SORTING")
@ -234,6 +238,55 @@ class GameModel(Model):
pass
# print("Execution")
def sort_orders(self):
orders_to_fill: [Order] = []
cut_orders: [Order] = []
for i in range(len(self.orderList)):
o: Order = self.orderList[i]
refrige = self.count_item_type(o, ItemType.REFRIGERATOR)
shelf = self.count_item_type(o, ItemType.SHELF)
door = self.count_item_type(o, ItemType.DOOR)
if self.count_shelf - shelf >= 0 and self.count_refrige - refrige >= 0 and self.count_door - door >= 0:
self.count_shelf -= shelf
self.count_door -= door
self.count_refrige -= refrige
orders_to_fill.append(o)
else:
cut_orders.append(o)
self.cut_orders = cut_orders
self.orderList = orders_to_fill
self.forklift_agent.orderList = orders_to_fill
def count_item_type(self, o: Order, itemType: ItemType) -> int:
res = 0
for i in range(len(o.items)):
it: Item = o.items[i]
if it.guessed_type == itemType:
res += 1
return res
def count_recognised_items(self):
count_refrige: int = 0
count_door: int = 0
count_shelf: int = 0
for i in range(len(self.recognised_items)):
item: Item = self.recognised_items[i]
if item.guessed_type == ItemType.DOOR:
count_door += 1
elif item.guessed_type == ItemType.SHELF:
count_shelf += 1
else:
count_refrige += 1
self.count_door = count_door
self.count_shelf = count_shelf
self.count_refrige = count_refrige
def recognise_item(self, item: Item):
val = image_classification(self.picture_visualization.img, self.classificator)
print("VAL: {}".format(val))