bfs na przycisk b
This commit is contained in:
parent
91a4e02c18
commit
34f3bb77f5
3
.idea/.gitignore
vendored
Normal file
3
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
8
.idea/Projekt_Si.iml
Normal file
8
.idea/Projekt_Si.iml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
6
.idea/inspectionProfiles/profiles_settings.xml
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
4
.idea/misc.xml
Normal file
4
.idea/misc.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10" project-jdk-type="Python SDK" />
|
||||
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/Projekt_Si.iml" filepath="$PROJECT_DIR$/.idea/Projekt_Si.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
51
app.py
51
app.py
@ -1,9 +1,9 @@
|
||||
import pygame
|
||||
import prefs
|
||||
import prefs
|
||||
from classes.beerKeg import BeerKeg
|
||||
from classes.coffeMachine import CoffeMachine
|
||||
from classes.table import Table
|
||||
from pygame.locals import K_w, K_s, K_a, K_d, K_q, K_e, K_r
|
||||
from pygame.locals import K_w, K_s, K_a, K_d, K_q, K_e, K_r, K_b
|
||||
from classes.cell import Cell
|
||||
from classes.agent import Agent
|
||||
from collections import deque
|
||||
@ -29,7 +29,7 @@ def initBoard():
|
||||
y1 = 6
|
||||
for i in range(x1, x1+4):
|
||||
for j in range(y1, y1+2):
|
||||
cells[i][j].prepareTexture("sprites/wall.png")
|
||||
cells[i][j].prepareTexture("sprites/wall.png")
|
||||
cells[i][j].blocking_movement = True
|
||||
|
||||
cells[6][4].interactableItem = BeerKeg(cells[6][4], "Beer Keg")
|
||||
@ -64,38 +64,8 @@ def draw_grid(window, cells, agent):
|
||||
initBoard()
|
||||
agent = Agent(prefs.SPAWN_POINT[0], prefs.SPAWN_POINT[1], cells)
|
||||
|
||||
#Wpisujemy miejsce w ktorym znajduje sie agent i miejsce docelowe do funkcji znajdujacej najkrotsza sciezke
|
||||
# start_cell = cells[5][5]
|
||||
# target_cell = cells[5][5]
|
||||
# shortest_path = agent.bfs(start_cell, target_cell, cells)
|
||||
|
||||
# if shortest_path:
|
||||
# print("Sciezka: ", [(cell.X, cell.Y) for cell in shortest_path])
|
||||
# else:
|
||||
# print("Brak sciezki")
|
||||
|
||||
# path = agent.convert_to_coordinates(shortest_path)
|
||||
|
||||
#osobny watek dla sciezki agenta zeby co *iles czasu* poruszal sie tam gdzie mowi path
|
||||
# def watekDlaSciezkiAgenta():
|
||||
# while True:
|
||||
# agent.sciezkaAgenta(agent,path)
|
||||
# time.sleep(1)
|
||||
|
||||
# watek = threading.Thread(target=watekDlaSciezkiAgenta)
|
||||
# watek.daemon = True
|
||||
# watek.start()
|
||||
|
||||
#target_x, target_y = 9,6
|
||||
#target_x, target_y = 5,2
|
||||
#target_x, target_y = 7,2
|
||||
#target_x, target_y = 8,2
|
||||
#target_x, target_y = 4,8
|
||||
#target_x, target_y = 0,9
|
||||
target_x, target_y = 9,11
|
||||
#target_x, target_y = 4,11
|
||||
#target_x, target_y = 6,3
|
||||
#target_x, target_y = 11,11
|
||||
|
||||
|
||||
#WYWOLUJEMY FUNKCJE SZUKAJACA LISTY AKCJI
|
||||
path = agent.bfs2(target_x, target_y)
|
||||
@ -110,9 +80,9 @@ def watekDlaSciezkiAgenta():
|
||||
if element =="left":
|
||||
agent.rotate_left()
|
||||
if element =="right":
|
||||
agent.rotate_right()
|
||||
agent.rotate_right()
|
||||
if element =="forward":
|
||||
agent.move_direction()
|
||||
agent.move_direction()
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
@ -125,7 +95,7 @@ while running:
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
running = False
|
||||
|
||||
|
||||
# takie głupie kontrolki do usunięcia potem, tylko do preznetacji
|
||||
|
||||
keys = pygame.key.get_pressed()
|
||||
@ -139,7 +109,7 @@ while running:
|
||||
agent.move_right()
|
||||
if not any([keys[K_w], keys[K_s], keys[K_a], keys[K_d]]):
|
||||
agent.moved = False
|
||||
|
||||
|
||||
if keys[K_q]:
|
||||
agent.rotate_left()
|
||||
if keys[K_e]:
|
||||
@ -147,7 +117,10 @@ while running:
|
||||
|
||||
if keys[K_r]:
|
||||
agent.move_direction()
|
||||
|
||||
|
||||
if keys[K_b]:
|
||||
path = agent.bfs2(target_x, target_y)
|
||||
|
||||
if pygame.key.get_pressed()[pygame.K_e]:
|
||||
if agent.current_cell.interactableItem and pygame.time.get_ticks() - agent.last_interact_time > 500:
|
||||
agent.last_interact_time = pygame.time.get_ticks()
|
||||
|
Loading…
Reference in New Issue
Block a user