created 20 shelfs

This commit is contained in:
shaaqu 2020-06-09 21:23:10 +02:00
parent 1b9049d613
commit 5c0f2d5f15
6 changed files with 86 additions and 23 deletions

View File

@ -3,13 +3,12 @@ import os
from codes_recognizer.rocognizer import recognizer
from board import get_shelfs
def assigning(product_code_path):
def assigning(product_code_path, board, shelfs):
code = recognizer(product_code_path)
shelfs = get_shelfs()
for shelf in shelfs:
if shelf.is_empty():
if shelf.is_empty:
shelf.add_product(code)
c = shelf.get_coordinates()
break

View File

@ -4,7 +4,7 @@ from field import Field
from shelf import Shelf
settings = Settings()
shelfs_o = []
def create_board(screen):
board = []
@ -24,7 +24,6 @@ def create_board(screen):
if field.center_x == shelf[0] and field.center_y == shelf[1]:
field.is_shelf = True
field.image = pygame.image.load('img/shelf.png')
shelfs_o.append(Shelf(x, y))
row.append(field)
board.append(row)
@ -52,6 +51,73 @@ def draw_board(board):
field.blitme()
def get_shelfs():
return shelfs_o
def get_shelfs(board):
field_shelfs = []
shelfs = []
for row in board:
for field in row:
if field.isShelf():
field_shelfs.append(field)
shelf = Shelf(field_shelfs[0], "01")
shelfs.append(shelf)
shelf = Shelf(field_shelfs[1], "01")
shelfs.append(shelf)
shelf = Shelf(field_shelfs[2], "02")
shelfs.append(shelf)
shelf = Shelf(field_shelfs[3], "02")
shelfs.append(shelf)
shelf = Shelf(field_shelfs[4], "03")
shelfs.append(shelf)
shelf = Shelf(field_shelfs[5], "03")
shelfs.append(shelf)
shelf = Shelf(field_shelfs[6], "04")
shelfs.append(shelf)
shelf = Shelf(field_shelfs[7], "04")
shelfs.append(shelf)
shelf = Shelf(field_shelfs[8], "05")
shelfs.append(shelf)
shelf = Shelf(field_shelfs[9], "05")
shelfs.append(shelf)
shelf = Shelf(field_shelfs[10], "06")
shelfs.append(shelf)
shelf = Shelf(field_shelfs[11], "06")
shelfs.append(shelf)
shelf = Shelf(field_shelfs[12], "07")
shelfs.append(shelf)
shelf = Shelf(field_shelfs[13], "07")
shelfs.append(shelf)
shelf = Shelf(field_shelfs[14], "08")
shelfs.append(shelf)
shelf = Shelf(field_shelfs[15], "08")
shelfs.append(shelf)
shelf = Shelf(field_shelfs[16], "09")
shelfs.append(shelf)
shelf = Shelf(field_shelfs[17], "09")
shelfs.append(shelf)
shelf = Shelf(field_shelfs[18], "10")
shelfs.append(shelf)
shelf = Shelf(field_shelfs[19], "10")
shelfs.append(shelf)
return shelfs

View File

@ -52,3 +52,6 @@ class Field:
def addShelf(self):
shelf = Shelf(len(self.shelves) + 1)
self.shelves.append(shelf)
def isShelf(self):
return self.is_shelf

View File

@ -23,6 +23,7 @@ def run():
# agent = Agent(screen, 550, 450, "Down")
agent = Agent(screen, 950, 950, "Left")
board = create_board(screen)
shelfs = get_shelfs(board)
my_tree = decision_tree.build_tree(data.learning_data)
products_from_supply = []
supply_depot = board[9][0]
@ -77,9 +78,8 @@ def run():
Wyznacza patha do polki na ktora ma polozyc produkt.
'''
# list [x, y]
dest_shelf = new_product.shelf()
dest_field = board[dest_shelf[0]][dest_shelf[1]]
path = functions.a_star(board[agent.y][agent.x], dest_field, board)
dest_shelf = new_product.shelf(board)
path = functions.a_star(board[agent.y][agent.x], dest_shelf.get_field(), board)
''''''
agent.item = new_product

View File

@ -31,6 +31,6 @@ class FinalProduct:
self.img = create_image(self)
def shelf(self):
def shelf(self, board):
print(self.img)
return assigning(self.img);
return assigning(self.img, board);

View File

@ -3,9 +3,9 @@ import pygame
class Shelf:
def __init__(self, x, y):
self.x = x
self.y = y
def __init__(self, field, color):
self.field = field
self.color = color
self.level1 = []
self.level2 = []
self.level3 = []
@ -22,13 +22,8 @@ class Shelf:
def get_product(self):
return self.products[0]
def get_coordinates(self):
c = [self.x, self.y]
return c
def get_field(self):
return self.field
def is_empty(self):
if len(self.products) == 0:
return True
else:
return False