AdamT_Podprojekt_Final
This commit is contained in:
parent
56689faa23
commit
172f97bc8c
@ -6,7 +6,7 @@ from kelner.src.managers.DrawableCollection import DrawableCollection
|
||||
from kelner.src.managers.MenuManager import MenuManager
|
||||
from kelner.src.managers.TableManager import TableManager
|
||||
from kelner.src.managers.WaiterManager import WaiterManager
|
||||
|
||||
from kelner.src.algorithms.DecisionTree import Tree_Builder
|
||||
|
||||
# create screen consts
|
||||
Scale = 2 # scale for all images used within project
|
||||
@ -26,6 +26,40 @@ drawableManager = DrawableCollection()
|
||||
# initialize menu manager
|
||||
menuManager = MenuManager()
|
||||
|
||||
##TESTING THE DECISION TREE
|
||||
#Testing Data
|
||||
testing_db = [
|
||||
[1, 0, 0, 0, "Kurczak"],
|
||||
[0, 1, 0, 0, "Piwo"],
|
||||
[0, 0, 1, 0, "Pizza"],
|
||||
[0, 0, 0, 1, "Salad"],
|
||||
|
||||
]
|
||||
|
||||
#Building a decision tree
|
||||
Test_Tree = Tree_Builder.build_tree(testing_db)
|
||||
|
||||
#Testing the tree
|
||||
if Tree_Builder.zgadnij(testing_db[0], Test_Tree) == "Kurczak":
|
||||
print("test1: passed")
|
||||
else:
|
||||
print("test1: fail")
|
||||
|
||||
if Tree_Builder.zgadnij(testing_db[1], Test_Tree) == "Piwo":
|
||||
print("test2: passed")
|
||||
else:
|
||||
print("test2: fail")
|
||||
|
||||
if Tree_Builder.zgadnij(testing_db[2], Test_Tree) == "Pizza":
|
||||
print("test3: passed")
|
||||
else:
|
||||
print("test3: fail")
|
||||
|
||||
if Tree_Builder.zgadnij(testing_db[3], Test_Tree) == "Salad":
|
||||
print("test4: passed")
|
||||
else:
|
||||
print("test4: fail")
|
||||
|
||||
|
||||
|
||||
# initialize waiter component
|
||||
|
@ -1,18 +1,18 @@
|
||||
import random
|
||||
|
||||
training_db = [
|
||||
[1, 0, 0, 'A'],
|
||||
[1, 1, 0,'B'],
|
||||
[0, 1, 0, 'C'],
|
||||
[0, 1, 1, 'B'],
|
||||
[0, 0, 1, 'D'],
|
||||
[1, 1, 0, 'B'],
|
||||
[1, 0, 0, 1, "Kurczak"],
|
||||
[1, 1, 0, 0, "Piwo"],
|
||||
[0, 1, 0, 0, "Pizza"],
|
||||
[0, 1, 1, 1, "Pizza"],
|
||||
[0, 0, 1, 0, "Salad"],
|
||||
[1, 1, 0, 1, "Cake"],
|
||||
|
||||
|
||||
]
|
||||
|
||||
|
||||
kolumny = ["sport", "czytanie", "lucznictwo", "jedzenie"]
|
||||
kolumny = ["sport", "czytanie", "lucznictwo", "boks", "jedzenie"]
|
||||
|
||||
|
||||
def kolumny_wartosci(rows, col):
|
||||
@ -124,9 +124,6 @@ def build_tree(rows):
|
||||
|
||||
|
||||
|
||||
print(spacing + '--> False:')
|
||||
print_tree(node.false_branch, spacing + " ")
|
||||
|
||||
|
||||
def zgadnij(row, node):
|
||||
if isinstance(node, Leaf):
|
||||
|
@ -32,16 +32,16 @@ class Table(Drawable):
|
||||
sport = random.randint(0,1)
|
||||
czytanie = random.randint(0,1)
|
||||
lucznictwo = random.randint(0,1)
|
||||
jedzenie = random.randint(0,1)
|
||||
self.__zainteresowania.append([sport,czytanie,lucznictwo,jedzenie, "A"])
|
||||
boks = random.randint(0,1)
|
||||
self.__zainteresowania.append([sport,czytanie,lucznictwo,boks, "A"])
|
||||
|
||||
def getOrder(self):
|
||||
# Generates order
|
||||
order = []
|
||||
for a in range(0,len(self.__guests)):
|
||||
order.append(Tree_Builder.zgadnij(self.__zainteresowania[a], self.Decision_Tree))
|
||||
print("Zamowienie: " + str(order))
|
||||
return order
|
||||
##def getOrder(self):
|
||||
## # Generates order
|
||||
## order = []
|
||||
## for a in range(0,len(self.__guests)):
|
||||
## order.append(Tree_Builder.zgadnij(self.__zainteresowania[a], self.Decision_Tree))
|
||||
## print("Zamowienie: " + str(order))
|
||||
## return order
|
||||
|
||||
@staticmethod
|
||||
def __getRandomGuests():
|
||||
@ -53,16 +53,46 @@ class Table(Drawable):
|
||||
return guests
|
||||
|
||||
# waiter collects orders from table
|
||||
##def getOrder(self):
|
||||
## order = None
|
||||
## if self.__tableLock.acquire(False):
|
||||
## try:
|
||||
## if self.isStatus(Status.Ready) and self.hasOrder():
|
||||
## order = self.__order
|
||||
## self.setOrder([])
|
||||
## finally:
|
||||
## self.__tableLock.release()
|
||||
## return order
|
||||
#def getOrder(self):
|
||||
# order = None
|
||||
# if self.__tableLock.acquire(False):
|
||||
# try:
|
||||
# if self.isStatus(Status.Ready):
|
||||
# # Generates order
|
||||
# order = []
|
||||
# for a in range(0,len(self.__guests)):
|
||||
# order.append(Tree_Builder.zgadnij(self.__zainteresowania[a], self.Decision_Tree))
|
||||
# print("Zamowienie: " + str(order))
|
||||
# finally:
|
||||
# self.__tableLock.release()
|
||||
# return order
|
||||
|
||||
# waiter collects orders from table
|
||||
def getOrder(self):
|
||||
order = None
|
||||
if self.__tableLock.acquire(False):
|
||||
try:
|
||||
if self.isStatus(Status.Ready) and self.hasOrder():
|
||||
# Generates order
|
||||
order = []
|
||||
for a in range(0,len(self.__guests)):
|
||||
order.append(Tree_Builder.zgadnij(self.__zainteresowania[a], self.Decision_Tree))
|
||||
print("Zamowienie: " + str(order))
|
||||
self.setOrder([])
|
||||
finally:
|
||||
self.__tableLock.release()
|
||||
return order
|
||||
|
||||
#def getOrder(self):
|
||||
# order = None
|
||||
# if self.__tableLock.acquire(False):
|
||||
# try:
|
||||
# if self.isStatus(Status.Ready) and self.hasOrder():
|
||||
# order = self.__order
|
||||
# self.setOrder([])
|
||||
# finally:
|
||||
# self.__tableLock.release()
|
||||
# return order
|
||||
|
||||
def setOrder(self, order):
|
||||
self.__order = order
|
||||
|
Loading…
Reference in New Issue
Block a user