forked from s474139/Inteligentny_Wozek
88 lines
2.6 KiB
Python
88 lines
2.6 KiB
Python
import sys
|
|
import pygame
|
|
import regal
|
|
import paczka
|
|
from wozek import Wozek
|
|
from wyszukiwanie import wyszukiwanie_bfs, Stan, SearchSpace
|
|
|
|
|
|
pygame.init()
|
|
screen = pygame.display.set_mode((980, 980))
|
|
miejsce = pygame.image.load('images/miejsce_paczek.png')
|
|
|
|
pygame.display.set_caption("Inteligentny wozek")
|
|
icon = pygame.image.load('images/icon.png')
|
|
pygame.display.set_icon(icon)
|
|
|
|
|
|
def main():
|
|
wozek = Wozek()
|
|
while True:
|
|
for event in pygame.event.get():
|
|
if event.type == pygame.QUIT:
|
|
sys.exit(0)
|
|
if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
|
|
sys.exit(0)
|
|
|
|
grid = SearchSpace()
|
|
# create start and goal states
|
|
start_state = Stan(x=1, y=0, kierunek=0) # for example
|
|
goal_state = Stan(x=12, y=0, kierunek=0) # for example
|
|
|
|
# perform BFS search
|
|
path = wyszukiwanie_bfs(start_state, goal_state, grid)
|
|
|
|
# print the path, if found
|
|
if path:
|
|
for p in path:
|
|
print(p.x, p.y)
|
|
print("Path found:", path)
|
|
else:
|
|
print("No path found.")
|
|
|
|
for state in path:
|
|
pygame.time.delay(200)
|
|
wozek.x = state.x
|
|
wozek.y = state.y
|
|
for event in pygame.event.get():
|
|
if event.type == pygame.QUIT:
|
|
sys.exit(0)
|
|
if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
|
|
sys.exit(0)
|
|
|
|
|
|
# Drawing
|
|
screen.fill((51,51,51)) # removes object trail
|
|
screen.blit(miejsce, (430, 400))
|
|
|
|
# idRegału, Długość regału podana w kratkach, Współrzędne od których ma być tworzony regał (wiersz,kolumna) - poziomo
|
|
# Współrzędne od (1,1) do (10,10)
|
|
regal.Regal(1, 1, 2, 2)
|
|
regal.Regal(2, 1, 2, 3)
|
|
regal.Regal(3, 1, 3, 2)
|
|
regal.Regal(4, 1, 3, 3)
|
|
|
|
regal.Regal(5, 1, 8, 2)
|
|
regal.Regal(6, 1, 8, 3)
|
|
regal.Regal(7, 1, 9, 2)
|
|
regal.Regal(8, 1, 9, 3)
|
|
|
|
regal.Regal(9, 1, 2, 8)
|
|
regal.Regal(10, 1, 2, 9)
|
|
regal.Regal(11, 1, 3, 8)
|
|
regal.Regal(12, 1, 3, 9)
|
|
|
|
regal.Regal(13, 1, 8, 8)
|
|
regal.Regal(14, 1, 8, 9)
|
|
regal.Regal(15, 1, 9, 8)
|
|
regal.Regal(16, 1, 9, 9)
|
|
|
|
wozek.draw()
|
|
|
|
pygame.display.flip() # updating frames
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|