diff --git a/__pycache__/board.cpython-37.pyc b/__pycache__/board.cpython-37.pyc index 9b06210..7d6e2b2 100644 Binary files a/__pycache__/board.cpython-37.pyc and b/__pycache__/board.cpython-37.pyc differ diff --git a/__pycache__/coder.cpython-37.pyc b/__pycache__/coder.cpython-37.pyc index 7d4ed71..43dd526 100644 Binary files a/__pycache__/coder.cpython-37.pyc and b/__pycache__/coder.cpython-37.pyc differ diff --git a/board.py b/board.py index 620b934..98ecdb0 100644 --- a/board.py +++ b/board.py @@ -13,7 +13,7 @@ def create_board(screen): (50, 50), (150, 50), (450, 50), (550, 50), (850, 50), (950, 50), (250, 250), (350, 250), (650, 250), (750, 250), (50, 450), (150, 450), (450, 450), (550, 450), (850, 450), (950, 450), - (250, 650), (350, 650), (650, 650), (750, 650), + (250, 650), (350, 650), (650, 650), (750, 650) ] for y in range(settings.y_fields): diff --git a/board.py.orig b/board.py.orig new file mode 100644 index 0000000..7977ba3 --- /dev/null +++ b/board.py.orig @@ -0,0 +1,130 @@ +import pygame +from settings import Settings +from field import Field +from shelf import Shelf + +settings = Settings() +#(250, 650), (250, 750) + +def create_board(screen): + board = [] +<<<<<<< HEAD +======= + +>>>>>>> upstream/master + shelfs = [ + (50, 50), (150, 50), (450, 50), (550, 50), (850, 50), (950, 50), + (250, 250), (350, 250), (650, 250), (750, 250), + (50, 450), (150, 450), (450, 450), (550, 450), (850, 450), (950, 450), +<<<<<<< HEAD + (250, 650), (350, 650), (650, 650), (750, 650) +======= + (250, 650), (350, 650), (650, 650), (750, 650), +>>>>>>> upstream/master + ] + + for y in range(settings.y_fields): + row = [] + for x in range(settings.x_fields): + field = Field(screen, x, y, 50 + x * 100, 50 + y * 100, False, False, 1) + for shelf in shelfs: + if field.center_x == shelf[0] and field.center_y == shelf[1]: + field.is_shelf = True + field.image = pygame.image.load('img/shelf.png') + + row.append(field) + board.append(row) + for row in board: + for field in row: + field.add_neighbors(board) + + for row in board: + for field in row: + if field.x > 0 and board[field.y][field.x - 1].is_shelf: + field.cost_of_travel += 1 + if field.x < 9 and board[field.y][field.x + 1].is_shelf: + field.cost_of_travel += 1 + if field.y > 0 and board[field.y - 1][field.x].is_shelf: + field.cost_of_travel += 1 + if field.y < 9 and board[field.y + 1][field.x].is_shelf: + field.cost_of_travel += 1 + + return board + + +def draw_board(board): + for row in board: + for field in row: + field.blitme() + + +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 + diff --git a/img/codes/Góralki.png b/img/codes/Góralki.png new file mode 100644 index 0000000..53a6511 Binary files /dev/null and b/img/codes/Góralki.png differ diff --git a/img/codes/Kinder-bueno.png b/img/codes/Kinder-bueno.png new file mode 100644 index 0000000..1ba42bf Binary files /dev/null and b/img/codes/Kinder-bueno.png differ diff --git a/img/codes/Korsarz Draże.png b/img/codes/Korsarz Draże.png new file mode 100644 index 0000000..61216d2 Binary files /dev/null and b/img/codes/Korsarz Draże.png differ diff --git a/img/shelves/black/black001.png b/img/shelves/black/black001.png new file mode 100644 index 0000000..aa3c7b7 Binary files /dev/null and b/img/shelves/black/black001.png differ diff --git a/img/shelves/black/black010.png b/img/shelves/black/black010.png new file mode 100644 index 0000000..17d028e Binary files /dev/null and b/img/shelves/black/black010.png differ diff --git a/img/shelves/black/black011.png b/img/shelves/black/black011.png new file mode 100644 index 0000000..eb97525 Binary files /dev/null and b/img/shelves/black/black011.png differ diff --git a/img/shelves/black/black100.png b/img/shelves/black/black100.png new file mode 100644 index 0000000..1f12227 Binary files /dev/null and b/img/shelves/black/black100.png differ diff --git a/img/shelves/black/black101.png b/img/shelves/black/black101.png new file mode 100644 index 0000000..8b80afc Binary files /dev/null and b/img/shelves/black/black101.png differ diff --git a/img/shelves/black/black110.png b/img/shelves/black/black110.png new file mode 100644 index 0000000..3fc3987 Binary files /dev/null and b/img/shelves/black/black110.png differ diff --git a/img/shelves/black/black111.png b/img/shelves/black/black111.png new file mode 100644 index 0000000..89cd871 Binary files /dev/null and b/img/shelves/black/black111.png differ diff --git a/img/shelves/blue/blue001.png b/img/shelves/blue/blue001.png new file mode 100644 index 0000000..056dc09 Binary files /dev/null and b/img/shelves/blue/blue001.png differ diff --git a/img/shelves/blue/blue010.png b/img/shelves/blue/blue010.png new file mode 100644 index 0000000..c204e34 Binary files /dev/null and b/img/shelves/blue/blue010.png differ diff --git a/img/shelves/blue/blue011.png b/img/shelves/blue/blue011.png new file mode 100644 index 0000000..b217040 Binary files /dev/null and b/img/shelves/blue/blue011.png differ diff --git a/img/shelves/blue/blue100.png b/img/shelves/blue/blue100.png new file mode 100644 index 0000000..aa3eb51 Binary files /dev/null and b/img/shelves/blue/blue100.png differ diff --git a/img/shelves/blue/blue101.png b/img/shelves/blue/blue101.png new file mode 100644 index 0000000..0a9ce6d Binary files /dev/null and b/img/shelves/blue/blue101.png differ diff --git a/img/shelves/blue/blue110.png b/img/shelves/blue/blue110.png new file mode 100644 index 0000000..2396724 Binary files /dev/null and b/img/shelves/blue/blue110.png differ diff --git a/img/shelves/blue/blue111.png b/img/shelves/blue/blue111.png new file mode 100644 index 0000000..8ccc92b Binary files /dev/null and b/img/shelves/blue/blue111.png differ diff --git a/img/shelves/brown/brown001.png b/img/shelves/brown/brown001.png new file mode 100644 index 0000000..92d521d Binary files /dev/null and b/img/shelves/brown/brown001.png differ diff --git a/img/shelves/brown/brown010.png b/img/shelves/brown/brown010.png new file mode 100644 index 0000000..492d1b2 Binary files /dev/null and b/img/shelves/brown/brown010.png differ diff --git a/img/shelves/brown/brown011.png b/img/shelves/brown/brown011.png new file mode 100644 index 0000000..d88b9eb Binary files /dev/null and b/img/shelves/brown/brown011.png differ diff --git a/img/shelves/brown/brown100.png b/img/shelves/brown/brown100.png new file mode 100644 index 0000000..a298b03 Binary files /dev/null and b/img/shelves/brown/brown100.png differ diff --git a/img/shelves/brown/brown101.png b/img/shelves/brown/brown101.png new file mode 100644 index 0000000..bcf968d Binary files /dev/null and b/img/shelves/brown/brown101.png differ diff --git a/img/shelves/brown/brown110.png b/img/shelves/brown/brown110.png new file mode 100644 index 0000000..f264daf Binary files /dev/null and b/img/shelves/brown/brown110.png differ diff --git a/img/shelves/brown/brown111.png b/img/shelves/brown/brown111.png new file mode 100644 index 0000000..92b5c76 Binary files /dev/null and b/img/shelves/brown/brown111.png differ diff --git a/img/shelves/gold/gold001.png b/img/shelves/gold/gold001.png new file mode 100644 index 0000000..a3112d9 Binary files /dev/null and b/img/shelves/gold/gold001.png differ diff --git a/img/shelves/gold/gold010.png b/img/shelves/gold/gold010.png new file mode 100644 index 0000000..bf6ed12 Binary files /dev/null and b/img/shelves/gold/gold010.png differ diff --git a/img/shelves/gold/gold011.png b/img/shelves/gold/gold011.png new file mode 100644 index 0000000..89fa745 Binary files /dev/null and b/img/shelves/gold/gold011.png differ diff --git a/img/shelves/gold/gold100.png b/img/shelves/gold/gold100.png new file mode 100644 index 0000000..0dc972c Binary files /dev/null and b/img/shelves/gold/gold100.png differ diff --git a/img/shelves/gold/gold101.png b/img/shelves/gold/gold101.png new file mode 100644 index 0000000..ecc78d6 Binary files /dev/null and b/img/shelves/gold/gold101.png differ diff --git a/img/shelves/gold/gold110.png b/img/shelves/gold/gold110.png new file mode 100644 index 0000000..090bc96 Binary files /dev/null and b/img/shelves/gold/gold110.png differ diff --git a/img/shelves/gold/gold111.png b/img/shelves/gold/gold111.png new file mode 100644 index 0000000..708010e Binary files /dev/null and b/img/shelves/gold/gold111.png differ diff --git a/img/shelves/orange/orange001.png b/img/shelves/orange/orange001.png new file mode 100644 index 0000000..8583d97 Binary files /dev/null and b/img/shelves/orange/orange001.png differ diff --git a/img/shelves/orange/orange010.png b/img/shelves/orange/orange010.png new file mode 100644 index 0000000..ca4ded7 Binary files /dev/null and b/img/shelves/orange/orange010.png differ diff --git a/img/shelves/orange/orange011.png b/img/shelves/orange/orange011.png new file mode 100644 index 0000000..400f8da Binary files /dev/null and b/img/shelves/orange/orange011.png differ diff --git a/img/shelves/orange/orange100.png b/img/shelves/orange/orange100.png new file mode 100644 index 0000000..69f90c4 Binary files /dev/null and b/img/shelves/orange/orange100.png differ diff --git a/img/shelves/orange/orange101.png b/img/shelves/orange/orange101.png new file mode 100644 index 0000000..93c3f7b Binary files /dev/null and b/img/shelves/orange/orange101.png differ diff --git a/img/shelves/orange/orange110.png b/img/shelves/orange/orange110.png new file mode 100644 index 0000000..6b07c54 Binary files /dev/null and b/img/shelves/orange/orange110.png differ diff --git a/img/shelves/orange/orange111.png b/img/shelves/orange/orange111.png new file mode 100644 index 0000000..b433c0f Binary files /dev/null and b/img/shelves/orange/orange111.png differ diff --git a/img/shelves/purple/purple001.png b/img/shelves/purple/purple001.png new file mode 100644 index 0000000..b66e5bc Binary files /dev/null and b/img/shelves/purple/purple001.png differ diff --git a/img/shelves/purple/purple010.png b/img/shelves/purple/purple010.png new file mode 100644 index 0000000..d746c48 Binary files /dev/null and b/img/shelves/purple/purple010.png differ diff --git a/img/shelves/purple/purple011.png b/img/shelves/purple/purple011.png new file mode 100644 index 0000000..93bd5e9 Binary files /dev/null and b/img/shelves/purple/purple011.png differ diff --git a/img/shelves/purple/purple100.png b/img/shelves/purple/purple100.png new file mode 100644 index 0000000..e3e6e47 Binary files /dev/null and b/img/shelves/purple/purple100.png differ diff --git a/img/shelves/purple/purple101.png b/img/shelves/purple/purple101.png new file mode 100644 index 0000000..ec9f327 Binary files /dev/null and b/img/shelves/purple/purple101.png differ diff --git a/img/shelves/purple/purple110.png b/img/shelves/purple/purple110.png new file mode 100644 index 0000000..12d5d15 Binary files /dev/null and b/img/shelves/purple/purple110.png differ diff --git a/img/shelves/purple/purple111.png b/img/shelves/purple/purple111.png new file mode 100644 index 0000000..46db8c4 Binary files /dev/null and b/img/shelves/purple/purple111.png differ diff --git a/img/shelves/red/red001.png b/img/shelves/red/red001.png new file mode 100644 index 0000000..5e518c6 Binary files /dev/null and b/img/shelves/red/red001.png differ diff --git a/img/shelves/red/red010.png b/img/shelves/red/red010.png new file mode 100644 index 0000000..805c874 Binary files /dev/null and b/img/shelves/red/red010.png differ diff --git a/img/shelves/red/red011.png b/img/shelves/red/red011.png new file mode 100644 index 0000000..3d3bfc8 Binary files /dev/null and b/img/shelves/red/red011.png differ diff --git a/img/shelves/red/red100.png b/img/shelves/red/red100.png new file mode 100644 index 0000000..cf45b02 Binary files /dev/null and b/img/shelves/red/red100.png differ diff --git a/img/shelves/red/red101.png b/img/shelves/red/red101.png new file mode 100644 index 0000000..5d20919 Binary files /dev/null and b/img/shelves/red/red101.png differ diff --git a/img/shelves/red/red110.png b/img/shelves/red/red110.png new file mode 100644 index 0000000..dc7f919 Binary files /dev/null and b/img/shelves/red/red110.png differ diff --git a/img/shelves/red/red111.png b/img/shelves/red/red111.png new file mode 100644 index 0000000..e4d2f09 Binary files /dev/null and b/img/shelves/red/red111.png differ diff --git a/img/shelves/silver/silver001.png b/img/shelves/silver/silver001.png new file mode 100644 index 0000000..481b98f Binary files /dev/null and b/img/shelves/silver/silver001.png differ diff --git a/img/shelves/silver/silver010.png b/img/shelves/silver/silver010.png new file mode 100644 index 0000000..d92f407 Binary files /dev/null and b/img/shelves/silver/silver010.png differ diff --git a/img/shelves/silver/silver011.png b/img/shelves/silver/silver011.png new file mode 100644 index 0000000..c095307 Binary files /dev/null and b/img/shelves/silver/silver011.png differ diff --git a/img/shelves/silver/silver100.png b/img/shelves/silver/silver100.png new file mode 100644 index 0000000..7785992 Binary files /dev/null and b/img/shelves/silver/silver100.png differ diff --git a/img/shelves/silver/silver101.png b/img/shelves/silver/silver101.png new file mode 100644 index 0000000..b4da91b Binary files /dev/null and b/img/shelves/silver/silver101.png differ diff --git a/img/shelves/silver/silver110.png b/img/shelves/silver/silver110.png new file mode 100644 index 0000000..5252603 Binary files /dev/null and b/img/shelves/silver/silver110.png differ diff --git a/img/shelves/silver/silver111.png b/img/shelves/silver/silver111.png new file mode 100644 index 0000000..df3827c Binary files /dev/null and b/img/shelves/silver/silver111.png differ diff --git a/img/shelves/white/white001.png b/img/shelves/white/white001.png new file mode 100644 index 0000000..795e1e3 Binary files /dev/null and b/img/shelves/white/white001.png differ diff --git a/img/shelves/white/white010.png b/img/shelves/white/white010.png new file mode 100644 index 0000000..6afaef6 Binary files /dev/null and b/img/shelves/white/white010.png differ diff --git a/img/shelves/white/white011.png b/img/shelves/white/white011.png new file mode 100644 index 0000000..1aa350a Binary files /dev/null and b/img/shelves/white/white011.png differ diff --git a/img/shelves/white/white100.png b/img/shelves/white/white100.png new file mode 100644 index 0000000..4a26ee4 Binary files /dev/null and b/img/shelves/white/white100.png differ diff --git a/img/shelves/white/white101.png b/img/shelves/white/white101.png new file mode 100644 index 0000000..29dee87 Binary files /dev/null and b/img/shelves/white/white101.png differ diff --git a/img/shelves/white/white110.png b/img/shelves/white/white110.png new file mode 100644 index 0000000..e767f22 Binary files /dev/null and b/img/shelves/white/white110.png differ diff --git a/img/shelves/white/white111.png b/img/shelves/white/white111.png new file mode 100644 index 0000000..4289143 Binary files /dev/null and b/img/shelves/white/white111.png differ diff --git a/img/shelves/yellow/yellow001.png b/img/shelves/yellow/yellow001.png new file mode 100644 index 0000000..72ea3af Binary files /dev/null and b/img/shelves/yellow/yellow001.png differ diff --git a/img/shelves/yellow/yellow010.png b/img/shelves/yellow/yellow010.png new file mode 100644 index 0000000..b2cea0c Binary files /dev/null and b/img/shelves/yellow/yellow010.png differ diff --git a/img/shelves/yellow/yellow011.png b/img/shelves/yellow/yellow011.png new file mode 100644 index 0000000..32d96b8 Binary files /dev/null and b/img/shelves/yellow/yellow011.png differ diff --git a/img/shelves/yellow/yellow100.png b/img/shelves/yellow/yellow100.png new file mode 100644 index 0000000..26f2b76 Binary files /dev/null and b/img/shelves/yellow/yellow100.png differ diff --git a/img/shelves/yellow/yellow101.png b/img/shelves/yellow/yellow101.png new file mode 100644 index 0000000..d0d0ced Binary files /dev/null and b/img/shelves/yellow/yellow101.png differ diff --git a/img/shelves/yellow/yellow110.png b/img/shelves/yellow/yellow110.png new file mode 100644 index 0000000..5f1aefd Binary files /dev/null and b/img/shelves/yellow/yellow110.png differ diff --git a/img/shelves/yellow/yellow111.png b/img/shelves/yellow/yellow111.png new file mode 100644 index 0000000..2bbf80b Binary files /dev/null and b/img/shelves/yellow/yellow111.png differ diff --git a/main.py.orig b/main.py.orig new file mode 100644 index 0000000..620926e --- /dev/null +++ b/main.py.orig @@ -0,0 +1,121 @@ +import pygame +import functions +import sys +import time +import decision_tree +import data + +from agent import Agent +from settings import Settings +from board import create_board, draw_board, get_shelfs +from random import randint, choice +from mcda import selectedSupply +from product import FinalProduct +from coder import create_image + + +# Inicjalizacja programu i utworzenie obiektu ekrany +def run(): + pygame.init() + settings = Settings() + screen = pygame.display.set_mode((settings.screen_width, settings.screen_height)) + pygame.display.set_caption("Inteligentny wózek widłowy") +<<<<<<< HEAD +======= + # agent = Agent(screen, 550, 450, "Down") +>>>>>>> upstream/master + 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] + + dest_field = None + path = [] + next_step = None + # Rozpoczęcie głównej pętli programu + while True: + # functions.check_events(agent, board) + # functions.update_screen(board, screen, agent) + # + for event in pygame.event.get(): + if event.type == pygame.QUIT: + sys.exit() + elif event.type == pygame.KEYDOWN: + if event.key == pygame.K_RIGHT: + agent.turn_right() + elif event.key == pygame.K_LEFT: + agent.turn_left() + elif event.key == pygame.K_UP: + agent.move_forward(board) + elif event.key == pygame.K_DOWN: + agent.item = None + agent.is_busy = False + elif event.key == pygame.K_SPACE: + products_from_supply = selectedSupply() + + # print("Wybrano: " + board[9][0].item[-1]) + # field = board[9][0] + # if not field.is_shelf: + # path = functions.a_star(board[agent.y][agent.x], field, board) + # path.pop(len(path) - 1) + # next_step = path.pop(len(path) - 1) + + if len(products_from_supply) != 0 and supply_depot.is_empty is True and agent.is_busy is False: + supply_depot.item = products_from_supply.pop(0) + print(supply_depot.item) + path = functions.a_star(board[agent.y][agent.x], supply_depot, board) + path.pop(len(path) - 1) + next_step = path.pop(len(path) - 1) + agent.is_busy = True + + if board[agent.y][agent.x].item and agent.item is None: + prediction = decision_tree.print_leaf(decision_tree.classify(board[agent.y][agent.x].item, my_tree)) + print("Agent uważa, że przedmiot to: " + prediction[0]) + new_product = FinalProduct(supply_depot.item[0], supply_depot.item[1], supply_depot.item[2], + supply_depot.item[3], prediction[0]) + print(new_product) + + ''' + Wyznacza patha do polki na ktora ma polozyc produkt. + ''' + # list [x, y] + dest_shelf = new_product.shelf(shelfs) + path = functions.a_star(board[agent.y][agent.x], dest_shelf.get_field(), board) + + '''''' + agent.item = new_product + path.pop(len(path) - 1) + next_step = path.pop(len(path) - 1) + agent.is_busy = True + + if board[agent.y][agent.x] == dest_field: + agent.is_busy = False + agent.item = None + + if next_step is not None: + time.sleep(0.5) + if functions.check_turn(agent, next_step): + agent.move_forward(board) + if len(path) != 0: + next_step = path.pop() + else: + next_step = None + # print(next_step, path) + for row in board: + for field in row: + if not field.is_shelf: + field.image = pygame.image.load('img/Field.png') + + else: + functions.change_turn(agent, next_step) + + draw_board(board) + agent.blitme() + + pygame.display.flip() + + + +run()