forked from s444420/AL-2020
created 20 shelfs
This commit is contained in:
parent
1b9049d613
commit
5c0f2d5f15
@ -3,13 +3,12 @@ import os
|
|||||||
from codes_recognizer.rocognizer import recognizer
|
from codes_recognizer.rocognizer import recognizer
|
||||||
from board import get_shelfs
|
from board import get_shelfs
|
||||||
|
|
||||||
def assigning(product_code_path):
|
def assigning(product_code_path, board, shelfs):
|
||||||
|
|
||||||
code = recognizer(product_code_path)
|
code = recognizer(product_code_path)
|
||||||
shelfs = get_shelfs()
|
|
||||||
|
|
||||||
for shelf in shelfs:
|
for shelf in shelfs:
|
||||||
if shelf.is_empty():
|
if shelf.is_empty:
|
||||||
shelf.add_product(code)
|
shelf.add_product(code)
|
||||||
c = shelf.get_coordinates()
|
c = shelf.get_coordinates()
|
||||||
break
|
break
|
||||||
|
74
board.py
74
board.py
@ -4,7 +4,7 @@ from field import Field
|
|||||||
from shelf import Shelf
|
from shelf import Shelf
|
||||||
|
|
||||||
settings = Settings()
|
settings = Settings()
|
||||||
shelfs_o = []
|
|
||||||
|
|
||||||
def create_board(screen):
|
def create_board(screen):
|
||||||
board = []
|
board = []
|
||||||
@ -24,7 +24,6 @@ def create_board(screen):
|
|||||||
if field.center_x == shelf[0] and field.center_y == shelf[1]:
|
if field.center_x == shelf[0] and field.center_y == shelf[1]:
|
||||||
field.is_shelf = True
|
field.is_shelf = True
|
||||||
field.image = pygame.image.load('img/shelf.png')
|
field.image = pygame.image.load('img/shelf.png')
|
||||||
shelfs_o.append(Shelf(x, y))
|
|
||||||
|
|
||||||
row.append(field)
|
row.append(field)
|
||||||
board.append(row)
|
board.append(row)
|
||||||
@ -52,6 +51,73 @@ def draw_board(board):
|
|||||||
field.blitme()
|
field.blitme()
|
||||||
|
|
||||||
|
|
||||||
def get_shelfs():
|
def get_shelfs(board):
|
||||||
return shelfs_o
|
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
|
||||||
|
|
||||||
|
3
field.py
3
field.py
@ -52,3 +52,6 @@ class Field:
|
|||||||
def addShelf(self):
|
def addShelf(self):
|
||||||
shelf = Shelf(len(self.shelves) + 1)
|
shelf = Shelf(len(self.shelves) + 1)
|
||||||
self.shelves.append(shelf)
|
self.shelves.append(shelf)
|
||||||
|
|
||||||
|
def isShelf(self):
|
||||||
|
return self.is_shelf
|
6
main.py
6
main.py
@ -23,6 +23,7 @@ def run():
|
|||||||
# agent = Agent(screen, 550, 450, "Down")
|
# agent = Agent(screen, 550, 450, "Down")
|
||||||
agent = Agent(screen, 950, 950, "Left")
|
agent = Agent(screen, 950, 950, "Left")
|
||||||
board = create_board(screen)
|
board = create_board(screen)
|
||||||
|
shelfs = get_shelfs(board)
|
||||||
my_tree = decision_tree.build_tree(data.learning_data)
|
my_tree = decision_tree.build_tree(data.learning_data)
|
||||||
products_from_supply = []
|
products_from_supply = []
|
||||||
supply_depot = board[9][0]
|
supply_depot = board[9][0]
|
||||||
@ -77,9 +78,8 @@ def run():
|
|||||||
Wyznacza patha do polki na ktora ma polozyc produkt.
|
Wyznacza patha do polki na ktora ma polozyc produkt.
|
||||||
'''
|
'''
|
||||||
# list [x, y]
|
# list [x, y]
|
||||||
dest_shelf = new_product.shelf()
|
dest_shelf = new_product.shelf(board)
|
||||||
dest_field = board[dest_shelf[0]][dest_shelf[1]]
|
path = functions.a_star(board[agent.y][agent.x], dest_shelf.get_field(), board)
|
||||||
path = functions.a_star(board[agent.y][agent.x], dest_field, board)
|
|
||||||
|
|
||||||
''''''
|
''''''
|
||||||
agent.item = new_product
|
agent.item = new_product
|
||||||
|
@ -31,6 +31,6 @@ class FinalProduct:
|
|||||||
|
|
||||||
self.img = create_image(self)
|
self.img = create_image(self)
|
||||||
|
|
||||||
def shelf(self):
|
def shelf(self, board):
|
||||||
print(self.img)
|
print(self.img)
|
||||||
return assigning(self.img);
|
return assigning(self.img, board);
|
||||||
|
17
shelf.py
17
shelf.py
@ -3,9 +3,9 @@ import pygame
|
|||||||
|
|
||||||
class Shelf:
|
class Shelf:
|
||||||
|
|
||||||
def __init__(self, x, y):
|
def __init__(self, field, color):
|
||||||
self.x = x
|
self.field = field
|
||||||
self.y = y
|
self.color = color
|
||||||
self.level1 = []
|
self.level1 = []
|
||||||
self.level2 = []
|
self.level2 = []
|
||||||
self.level3 = []
|
self.level3 = []
|
||||||
@ -22,13 +22,8 @@ class Shelf:
|
|||||||
def get_product(self):
|
def get_product(self):
|
||||||
return self.products[0]
|
return self.products[0]
|
||||||
|
|
||||||
def get_coordinates(self):
|
def get_field(self):
|
||||||
c = [self.x, self.y]
|
return self.field
|
||||||
return c
|
|
||||||
|
|
||||||
def is_empty(self):
|
|
||||||
if len(self.products) == 0:
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user