Merge branch 'master' of s444428/AL-2020 into master
2
board.py
@ -13,7 +13,7 @@ def create_board(screen):
|
|||||||
(50, 50), (150, 50), (450, 50), (550, 50), (850, 50), (950, 50),
|
(50, 50), (150, 50), (450, 50), (550, 50), (850, 50), (950, 50),
|
||||||
(250, 250), (350, 250), (650, 250), (750, 250),
|
(250, 250), (350, 250), (650, 250), (750, 250),
|
||||||
(50, 450), (150, 450), (450, 450), (550, 450), (850, 450), (950, 450),
|
(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):
|
for y in range(settings.y_fields):
|
||||||
|
130
board.py.orig
Normal file
@ -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
|
||||||
|
|
BIN
img/codes/Góralki.png
Normal file
After Width: | Height: | Size: 8.1 KiB |
BIN
img/codes/Kinder-bueno.png
Normal file
After Width: | Height: | Size: 7.7 KiB |
BIN
img/codes/Korsarz Draże.png
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
img/shelves/black/black001.png
Normal file
After Width: | Height: | Size: 860 B |
BIN
img/shelves/black/black010.png
Normal file
After Width: | Height: | Size: 857 B |
BIN
img/shelves/black/black011.png
Normal file
After Width: | Height: | Size: 867 B |
BIN
img/shelves/black/black100.png
Normal file
After Width: | Height: | Size: 856 B |
BIN
img/shelves/black/black101.png
Normal file
After Width: | Height: | Size: 867 B |
BIN
img/shelves/black/black110.png
Normal file
After Width: | Height: | Size: 864 B |
BIN
img/shelves/black/black111.png
Normal file
After Width: | Height: | Size: 872 B |
BIN
img/shelves/blue/blue001.png
Normal file
After Width: | Height: | Size: 896 B |
BIN
img/shelves/blue/blue010.png
Normal file
After Width: | Height: | Size: 894 B |
BIN
img/shelves/blue/blue011.png
Normal file
After Width: | Height: | Size: 927 B |
BIN
img/shelves/blue/blue100.png
Normal file
After Width: | Height: | Size: 886 B |
BIN
img/shelves/blue/blue101.png
Normal file
After Width: | Height: | Size: 922 B |
BIN
img/shelves/blue/blue110.png
Normal file
After Width: | Height: | Size: 918 B |
BIN
img/shelves/blue/blue111.png
Normal file
After Width: | Height: | Size: 950 B |
BIN
img/shelves/brown/brown001.png
Normal file
After Width: | Height: | Size: 900 B |
BIN
img/shelves/brown/brown010.png
Normal file
After Width: | Height: | Size: 898 B |
BIN
img/shelves/brown/brown011.png
Normal file
After Width: | Height: | Size: 930 B |
BIN
img/shelves/brown/brown100.png
Normal file
After Width: | Height: | Size: 890 B |
BIN
img/shelves/brown/brown101.png
Normal file
After Width: | Height: | Size: 925 B |
BIN
img/shelves/brown/brown110.png
Normal file
After Width: | Height: | Size: 921 B |
BIN
img/shelves/brown/brown111.png
Normal file
After Width: | Height: | Size: 955 B |
BIN
img/shelves/gold/gold001.png
Normal file
After Width: | Height: | Size: 901 B |
BIN
img/shelves/gold/gold010.png
Normal file
After Width: | Height: | Size: 899 B |
BIN
img/shelves/gold/gold011.png
Normal file
After Width: | Height: | Size: 931 B |
BIN
img/shelves/gold/gold100.png
Normal file
After Width: | Height: | Size: 891 B |
BIN
img/shelves/gold/gold101.png
Normal file
After Width: | Height: | Size: 926 B |
BIN
img/shelves/gold/gold110.png
Normal file
After Width: | Height: | Size: 922 B |
BIN
img/shelves/gold/gold111.png
Normal file
After Width: | Height: | Size: 956 B |
BIN
img/shelves/orange/orange001.png
Normal file
After Width: | Height: | Size: 893 B |
BIN
img/shelves/orange/orange010.png
Normal file
After Width: | Height: | Size: 891 B |
BIN
img/shelves/orange/orange011.png
Normal file
After Width: | Height: | Size: 924 B |
BIN
img/shelves/orange/orange100.png
Normal file
After Width: | Height: | Size: 884 B |
BIN
img/shelves/orange/orange101.png
Normal file
After Width: | Height: | Size: 919 B |
BIN
img/shelves/orange/orange110.png
Normal file
After Width: | Height: | Size: 915 B |
BIN
img/shelves/orange/orange111.png
Normal file
After Width: | Height: | Size: 947 B |
BIN
img/shelves/purple/purple001.png
Normal file
After Width: | Height: | Size: 898 B |
BIN
img/shelves/purple/purple010.png
Normal file
After Width: | Height: | Size: 896 B |
BIN
img/shelves/purple/purple011.png
Normal file
After Width: | Height: | Size: 929 B |
BIN
img/shelves/purple/purple100.png
Normal file
After Width: | Height: | Size: 889 B |
BIN
img/shelves/purple/purple101.png
Normal file
After Width: | Height: | Size: 924 B |
BIN
img/shelves/purple/purple110.png
Normal file
After Width: | Height: | Size: 920 B |
BIN
img/shelves/purple/purple111.png
Normal file
After Width: | Height: | Size: 953 B |
BIN
img/shelves/red/red001.png
Normal file
After Width: | Height: | Size: 900 B |
BIN
img/shelves/red/red010.png
Normal file
After Width: | Height: | Size: 898 B |
BIN
img/shelves/red/red011.png
Normal file
After Width: | Height: | Size: 930 B |
BIN
img/shelves/red/red100.png
Normal file
After Width: | Height: | Size: 890 B |
BIN
img/shelves/red/red101.png
Normal file
After Width: | Height: | Size: 925 B |
BIN
img/shelves/red/red110.png
Normal file
After Width: | Height: | Size: 921 B |
BIN
img/shelves/red/red111.png
Normal file
After Width: | Height: | Size: 955 B |
BIN
img/shelves/silver/silver001.png
Normal file
After Width: | Height: | Size: 891 B |
BIN
img/shelves/silver/silver010.png
Normal file
After Width: | Height: | Size: 890 B |
BIN
img/shelves/silver/silver011.png
Normal file
After Width: | Height: | Size: 922 B |
BIN
img/shelves/silver/silver100.png
Normal file
After Width: | Height: | Size: 882 B |
BIN
img/shelves/silver/silver101.png
Normal file
After Width: | Height: | Size: 917 B |
BIN
img/shelves/silver/silver110.png
Normal file
After Width: | Height: | Size: 914 B |
BIN
img/shelves/silver/silver111.png
Normal file
After Width: | Height: | Size: 945 B |
BIN
img/shelves/white/white001.png
Normal file
After Width: | Height: | Size: 876 B |
BIN
img/shelves/white/white010.png
Normal file
After Width: | Height: | Size: 871 B |
BIN
img/shelves/white/white011.png
Normal file
After Width: | Height: | Size: 896 B |
BIN
img/shelves/white/white100.png
Normal file
After Width: | Height: | Size: 870 B |
BIN
img/shelves/white/white101.png
Normal file
After Width: | Height: | Size: 895 B |
BIN
img/shelves/white/white110.png
Normal file
After Width: | Height: | Size: 890 B |
BIN
img/shelves/white/white111.png
Normal file
After Width: | Height: | Size: 913 B |
BIN
img/shelves/yellow/yellow001.png
Normal file
After Width: | Height: | Size: 877 B |
BIN
img/shelves/yellow/yellow010.png
Normal file
After Width: | Height: | Size: 872 B |
BIN
img/shelves/yellow/yellow011.png
Normal file
After Width: | Height: | Size: 897 B |
BIN
img/shelves/yellow/yellow100.png
Normal file
After Width: | Height: | Size: 871 B |
BIN
img/shelves/yellow/yellow101.png
Normal file
After Width: | Height: | Size: 897 B |
BIN
img/shelves/yellow/yellow110.png
Normal file
After Width: | Height: | Size: 891 B |
BIN
img/shelves/yellow/yellow111.png
Normal file
After Width: | Height: | Size: 914 B |
121
main.py.orig
Normal file
@ -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()
|