diff --git a/__pycache__/data.cpython-38.pyc b/__pycache__/data.cpython-38.pyc index 82c5772..4a63ec5 100644 Binary files a/__pycache__/data.cpython-38.pyc and b/__pycache__/data.cpython-38.pyc differ diff --git a/__pycache__/field.cpython-38.pyc b/__pycache__/field.cpython-38.pyc index 4413c80..4a8c22c 100644 Binary files a/__pycache__/field.cpython-38.pyc and b/__pycache__/field.cpython-38.pyc differ diff --git a/__pycache__/mcda.cpython-38.pyc b/__pycache__/mcda.cpython-38.pyc index 79e10a9..5b843ed 100644 Binary files a/__pycache__/mcda.cpython-38.pyc and b/__pycache__/mcda.cpython-38.pyc differ diff --git a/__pycache__/supply.cpython-38.pyc b/__pycache__/supply.cpython-38.pyc index 8dba534..960d057 100644 Binary files a/__pycache__/supply.cpython-38.pyc and b/__pycache__/supply.cpython-38.pyc differ diff --git a/data.py b/data.py index 4c3a444..e714882 100644 --- a/data.py +++ b/data.py @@ -32,7 +32,7 @@ learning_data = [ # kolor, kształt, waga, rozmiar, nazwa ['black', 'rectangle', 51, 'small', 'Mars'], ['gold', 'pack', 100, 'big', 'Haribo'], - ['purple', 'rectangle', 100, 'big', 'Milka'], + ['purple', 'rectangle', 100, 'big', 'Milka-czekolada'], ['brown', 'pack', 45, 'small', 'M&M'], ['blue', 'rectangle', 50, 'medium', 'Bounty'], ['blue', 'square', 40, 'small', 'Knoppers'], @@ -43,7 +43,7 @@ learning_data = [ ['brown', 'rectangle', 45, 'medium', 'Lion'], ['white', 'rectangle', 40, 'medium', 'Kinder-bueno'], ['red', 'rectangle', 50, 'medium', 'Kit-kat'], - ['blue', 'rectangle', 115, 'big', 'Wedel'], + ['blue', 'rectangle', 115, 'big', 'Wedel-czekolada'], ['white', 'rectangle', 15, 'small', 'Krowka'], ['red', 'pack', 70, 'medium', 'Skittles'], ['orange', 'rectangle', 45, 'medium', 'Reeses'], @@ -57,6 +57,29 @@ learning_data = [ ['red', 'jar', 250, 'medium', 'Strawberry Jam'], ['black', 'jar', 250, 'medium', 'Blackberry Jam'], ['orange', 'jar', 250, 'medium', 'Peach Jam'], + ['brown', 'rectangle', 140, 'big', 'Jezyki classic'], + ['blue', 'rectangle', 140, 'big', 'Jezyki kokos'], + ['white', 'rectangle', 100, 'big', 'Kinder Chocolate'], + ['yellow', 'rectangle', 300, 'big', 'belVita'], + ['blue', 'rectangle', 380, 'big', 'Wedel-Ptasie Mleczko'], + ['purple', 'rectangle', 330, 'big', 'Milka-Alpejskie Mleczko'], + ['blue', 'rectangle', 294, 'big', 'Delicje'], + ['silver', 'pack', 280, 'big', 'Wawel-Michalki'], + ['red', 'rectangle', 50, 'medium', 'Krakuski Petit Beurre'], + ['white', 'egg', 20, 'small', 'Kinder Niespodzianka'], + ['brown', 'rectangle', 180, 'big', 'Familijne Wafle'], + ['red', 'rectangle', 235, 'big', 'dr Gerard PryncyPałki'], + ['white', 'rectangle', 25, 'medium', 'Nestlé Cini Minis Batonik'], + ['black', 'pack', 70, 'big', 'Korsarz Draże'], + ['white', 'rectangle', 50, 'medium', 'Góralki'], + ['white', 'rectangle', 24, 'medium', 'Kinder Country'], + ['red', 'rectangle', 46, 'medium', '3Bit'], + ['yellow', 'rectangle', 25, 'medium', 'Nestlé Nesquik Batonik'], + ['yellow', 'rectangle', 47, 'medium', 'Wedel WW'], + ['brown', 'rectangle', 30, 'medium', 'Lubisie'], + ['purple', 'rectangle', 22, 'small', 'Maoam'], + ['brown', 'rectangle', 294, 'medium', 'Grześki'], + ['white', 'rectangle', 250, 'big', 'merci'], ] diff --git a/main.py b/main.py index 177f331..9afec3b 100644 --- a/main.py +++ b/main.py @@ -9,7 +9,7 @@ from agent import Agent from settings import Settings from board import create_board, draw_board from random import randint, choice -from mcda import choseProducts +from mcda import selectedSupply # Inicjalizacja programu i utworzenie obiektu ekrany @@ -22,7 +22,7 @@ def run(): board = create_board(screen) my_tree = decision_tree.build_tree(data.learning_data) - produsctsFromSupply = choseProducts(5) + produsctsFromSupply = selectedSupply() # for row in board: # for field in row: diff --git a/mcda.py b/mcda.py index 68dd463..e8c17f2 100644 --- a/mcda.py +++ b/mcda.py @@ -1,9 +1,9 @@ from supply import * -allProducts = create_data_products() +allProducts = supply() -color = {'black': 16, 'gold': 10, 'purple': 5, 'brown': 7, 'blue': 12, 'white': 14, 'red': 13, 'orange': 11} -shape = {'rectangle': 15, 'pack': 19, 'square': 9, 'jar': 7} +color = {'black': 16, 'gold': 10, 'purple': 12, 'brown': 7, 'blue': 12, 'white': 14, 'red': 13, 'orange': 11, 'yellow': 8, 'silver': 15} +shape = {'rectangle': 15, 'pack': 19, 'square': 9, 'jar': 7, 'egg': 12} size = {'small': 7, 'medium': 16, 'big': 13} def sizeValue(X): @@ -68,12 +68,11 @@ def getConcordanceAllProducts(): C.append(c) return C -def choseProducts(number): +def choseProducts(): + number = 20 C = getConcordanceAllProducts() products = [] prev = -1 - if number > len(allProducts): - return allProducts while number > 0: max = -1 if prev == -1: @@ -89,11 +88,28 @@ def choseProducts(number): max = j prev = max for j in range(len(allProducts)): - if C[max] == C[j]: - products.append(allProducts[j]) - print(C[j]) - number -= 1 - if number == 0: - break - print(C) - return products \ No newline at end of file + if C[max] > 0.8: + if C[max] == C[j]: + products.append(allProducts[j]) + print(C[j]) + number -= 1 + if number == 0: + break + else: + number = 0 + return products + +def selectedSupply(): + products = choseProducts() + supply = [] + product = ['-', '-', 0, '-', '-'] + for i in range(len(products)): + product[0] = products[i].color + product[1] = products[i].shape + product[2] = products[i].mass + product[3] = products[i].size + supply.append(product) + product = ['-', '-', 0, '-', '-'] + supply.append(product) + print(supply) + return supply \ No newline at end of file diff --git a/supply.py b/supply.py index 673b31a..a574768 100644 --- a/supply.py +++ b/supply.py @@ -1,11 +1,10 @@ from product import Product +import random def create_data_products(): allProducts = [] - product = Product('black', 'rectangle', 51, 'small') - allProducts.append(product) product = Product('black', 'rectangle', 51, 'small') allProducts.append(product) product = Product('gold', 'pack', 100, 'big') @@ -60,5 +59,63 @@ def create_data_products(): allProducts.append(product) product = Product('orange', 'jar', 250, 'medium') allProducts.append(product) + product = Product('brown', 'rectangle', 140, 'big') + allProducts.append(product) + product = Product('blue', 'rectangle', 140, 'big') + allProducts.append(product) + product = Product('white', 'rectangle', 100, 'big') + allProducts.append(product) + product = Product('yellow', 'rectangle', 300, 'big') + allProducts.append(product) + product = Product('blue', 'rectangle', 380, 'big') + allProducts.append(product) + product = Product('purple', 'rectangle', 330, 'big') + allProducts.append(product) + product = Product('blue', 'rectangle', 294, 'big') + allProducts.append(product) + product = Product('silver', 'pack', 280, 'big') + allProducts.append(product) + product = Product('red', 'rectangle', 50, 'medium') + allProducts.append(product) + product = Product('white', 'egg', 20, 'small') + allProducts.append(product) + product = Product('brown', 'rectangle', 180, 'big') + allProducts.append(product) + product = Product('red', 'rectangle', 235, 'big') + allProducts.append(product) + product = Product('white', 'rectangle', 25, 'medium') + allProducts.append(product) + product = Product('black', 'pack', 70, 'big') + allProducts.append(product) + product = Product('white', 'rectangle', 50, 'medium') + allProducts.append(product) + product = Product('white', 'rectangle', 24, 'medium') + allProducts.append(product) + product = Product('red', 'rectangle', 46, 'medium') + allProducts.append(product) + product = Product('yellow', 'rectangle', 25, 'medium') + allProducts.append(product) + product = Product('yellow', 'rectangle', 47, 'medium') + allProducts.append(product) + product = Product('brown', 'rectangle', 30, 'medium') + allProducts.append(product) + product = Product('purple', 'rectangle', 22, 'small') + allProducts.append(product) + product = Product('brown', 'rectangle', 294, 'medium') + allProducts.append(product) + product = Product('white', 'rectangle', 250, 'big') + allProducts.append(product) + + return allProducts + +def supply(): + allProducts = create_data_products() + R = [] + supply = [] + while len(R)<20: + rand = random.randint(0, 49) + if R.count(rand) == 0: + R.append(rand) + supply.append(allProducts[rand]) + return supply - return allProducts \ No newline at end of file