Merge branch 'master' of s444428/AL-2020 into master

This commit is contained in:
Wojciech Łukasik 2020-06-09 20:56:57 +00:00 committed by Gogs
commit 2b1b66f3b3
78 changed files with 252 additions and 1 deletions

Binary file not shown.

Binary file not shown.

View File

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

130
board.py.orig Normal file
View 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

BIN
img/codes/Kinder-bueno.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 860 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 857 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 867 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 856 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 867 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 864 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 872 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 896 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 894 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 927 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 886 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 922 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 918 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 950 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 900 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 898 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 930 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 890 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 925 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 921 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 955 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 901 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 899 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 931 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 891 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 926 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 922 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 956 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 893 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 891 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 924 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 884 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 919 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 915 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 947 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 898 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 896 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 929 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 889 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 924 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 920 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 953 B

BIN
img/shelves/red/red001.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 900 B

BIN
img/shelves/red/red010.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 898 B

BIN
img/shelves/red/red011.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 930 B

BIN
img/shelves/red/red100.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 890 B

BIN
img/shelves/red/red101.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 925 B

BIN
img/shelves/red/red110.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 921 B

BIN
img/shelves/red/red111.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 955 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 891 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 890 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 922 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 882 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 917 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 914 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 945 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 876 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 871 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 896 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 870 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 895 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 890 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 913 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 877 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 872 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 897 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 871 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 897 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 891 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 914 B

121
main.py.orig Normal file
View 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()