Inteligentny_Wozek/main.py

88 lines
2.6 KiB
Python
Raw Normal View History

import sys
2023-03-21 12:36:50 +01:00
import pygame
import regal
import paczka
2023-04-20 20:54:58 +02:00
from wozek import Wozek
2023-04-20 23:16:34 +02:00
from wyszukiwanie import wyszukiwanie_bfs, Stan, SearchSpace
pygame.init()
2023-03-11 13:46:05 +01:00
screen = pygame.display.set_mode((980, 980))
2023-03-26 23:01:16 +02:00
miejsce = pygame.image.load('images/miejsce_paczek.png')
2023-03-11 13:26:14 +01:00
2023-03-26 21:21:52 +02:00
pygame.display.set_caption("Inteligentny wozek")
icon = pygame.image.load('images/icon.png')
pygame.display.set_icon(icon)
2023-03-11 13:26:14 +01:00
def main():
2023-03-11 00:44:46 +01:00
wozek = Wozek()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit(0)
2023-03-26 21:21:52 +02:00
if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
2023-03-11 00:44:46 +01:00
sys.exit(0)
2023-04-20 23:16:34 +02:00
grid = SearchSpace()
# create start and goal states
start_state = Stan(x=0, y=0, kierunek=0) # for example
goal_state = Stan(x=0, y=1, 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
2023-03-11 00:44:46 +01:00
if __name__ == "__main__":
main()
2023-04-20 23:16:34 +02:00