2
0
forked from s444420/AL-2020

Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Wojciech Łukasik 2020-06-08 18:29:52 +02:00
commit 1e7680181f
8 changed files with 117 additions and 21 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

27
data.py
View File

@ -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'],
]

View File

@ -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:

30
mcda.py
View File

@ -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] > 0.8:
if C[max] == C[j]:
products.append(allProducts[j])
print(C[j])
number -= 1
if number == 0:
break
print(C)
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

View File

@ -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