fixed lagged package
This commit is contained in:
parent
0529f89343
commit
3bb8657b17
33
docs/docs.md
Normal file
33
docs/docs.md
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# PROJEKT AI
|
||||||
|
### FUNKCJE I STRUKTURY
|
||||||
|
[`get_pix_from_position`](#####get_pix_from_position)
|
||||||
|
[`get_position_from_pix()`](#####get_position_from_pix())
|
||||||
|
[`create_positions()`](#####create_positions())
|
||||||
|
[`generate_package()`](#####generate_package())
|
||||||
|
[`breadth_first_search()`](#####breadth_first_search())
|
||||||
|
### KLASY
|
||||||
|
[`Node`](####Node)
|
||||||
|
[`Package`](####Package)
|
||||||
|
[`Shelf`](####Shelf)
|
||||||
|
[`Agent`](####Agent)
|
||||||
|
|
||||||
|
### MAIN
|
||||||
|
|
||||||
|
go to [`lol`](####LOL)
|
||||||
|
|
||||||
|
## FUNKCJE I STRUKTURY
|
||||||
|
|
||||||
|
##### get_pix_from_position
|
||||||
|
##### get_position_from_pix()
|
||||||
|
##### create_positions()
|
||||||
|
##### generate_package()
|
||||||
|
##### breadth_first_search()
|
||||||
|
|
||||||
|
## KLASY
|
||||||
|
|
||||||
|
#### Node
|
||||||
|
#### Package
|
||||||
|
#### Shelf
|
||||||
|
#### Agent
|
||||||
|
|
||||||
|
## MAIN
|
15
src/main.py
15
src/main.py
@ -458,7 +458,7 @@ for index_x in range(9):
|
|||||||
running = True
|
running = True
|
||||||
|
|
||||||
while running:
|
while running:
|
||||||
time.sleep(0.25)
|
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
if event.type == pygame.QUIT:
|
if event.type == pygame.QUIT:
|
||||||
running = False
|
running = False
|
||||||
@ -466,11 +466,7 @@ while running:
|
|||||||
if event.type == pygame.KEYDOWN:
|
if event.type == pygame.KEYDOWN:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
for package in Package_list:
|
|
||||||
if package.is_package_up:
|
|
||||||
package.rect.move_ip(agent.pos[0] - package.pos[0], agent.pos[1] - package.pos[1])
|
|
||||||
|
|
||||||
package.pos = agent.pos
|
|
||||||
|
|
||||||
if len(Package_list) < QTY_OF_PACKAGES:
|
if len(Package_list) < QTY_OF_PACKAGES:
|
||||||
|
|
||||||
@ -486,11 +482,9 @@ while running:
|
|||||||
# PATHING
|
# PATHING
|
||||||
if not agent.goal_achieved:
|
if not agent.goal_achieved:
|
||||||
print(agent.path)
|
print(agent.path)
|
||||||
|
|
||||||
agent.move_bfs()
|
agent.move_bfs()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
time.sleep(.25)
|
|
||||||
|
|
||||||
agent.lift_package_bfs()
|
agent.lift_package_bfs()
|
||||||
if coord_goals:
|
if coord_goals:
|
||||||
@ -500,6 +494,11 @@ while running:
|
|||||||
# agent.path = breadth_first_search(agent.pos_coord, agent.agent_direction)
|
# agent.path = breadth_first_search(agent.pos_coord, agent.agent_direction)
|
||||||
agent.path = a_star_search((agent.pos_coord[1], agent.pos_coord[0]), (agent.goal[1], agent.goal[0]), agent.agent_direction)
|
agent.path = a_star_search((agent.pos_coord[1], agent.pos_coord[0]), (agent.goal[1], agent.goal[0]), agent.agent_direction)
|
||||||
|
|
||||||
|
for package in Package_list:
|
||||||
|
if package.is_package_up:
|
||||||
|
package.rect.move_ip(agent.pos[0] - package.pos[0], agent.pos[1] - package.pos[1])
|
||||||
|
package.pos = agent.pos
|
||||||
|
|
||||||
# DRAWING
|
# DRAWING
|
||||||
screen.blit(BACKGROUND, [0, 0])
|
screen.blit(BACKGROUND, [0, 0])
|
||||||
screen.blit(DOCK, [0, 0])
|
screen.blit(DOCK, [0, 0])
|
||||||
@ -512,6 +511,8 @@ while running:
|
|||||||
for package in Package_list:
|
for package in Package_list:
|
||||||
screen.blit(package.image, package.rect)
|
screen.blit(package.image, package.rect)
|
||||||
|
|
||||||
|
time.sleep(0.15)
|
||||||
|
|
||||||
pygame.display.update()
|
pygame.display.update()
|
||||||
|
|
||||||
pygame.quit()
|
pygame.quit()
|
||||||
|
Loading…
Reference in New Issue
Block a user