Poprawka, by zamykało okno gdy wszystkie paczki są na swoich miejscach
This commit is contained in:
parent
7606871afb
commit
42f79f165a
8
agent.py
8
agent.py
@ -3,6 +3,8 @@ from queue import PriorityQueue
|
||||
from math import sqrt
|
||||
from attributes import TURN_LEFT_DIRECTIONS, TURN_RIGHT_DIRECTIONS, PackStatus, PackSize
|
||||
import pdb
|
||||
import pygame
|
||||
import sys
|
||||
|
||||
class Node:
|
||||
def __init__(self, coord_x, coord_y, package=None, is_rack=False):
|
||||
@ -111,7 +113,6 @@ class Agent:
|
||||
def move(self):
|
||||
dest_coords = (self.dest.x, self.dest.y)
|
||||
if not self.path:
|
||||
print("chuj")
|
||||
if not self.find_path():
|
||||
return
|
||||
else:
|
||||
@ -166,7 +167,7 @@ class Agent:
|
||||
packages_costs = []
|
||||
start_node = Node(self.x, self.y)
|
||||
if not self.warehouse.packages:
|
||||
return
|
||||
return None
|
||||
for package in self.warehouse.packages:
|
||||
if package.status == PackStatus.STORED:
|
||||
continue
|
||||
@ -174,6 +175,9 @@ class Agent:
|
||||
cost = self.heuristic(start_node, new_node)
|
||||
if cost > 0:
|
||||
packages_costs.append((package, cost))
|
||||
if not packages_costs:
|
||||
pygame.quit()
|
||||
sys.exit()
|
||||
package = min(packages_costs, key=lambda l: l[1])[0]
|
||||
return package
|
||||
|
||||
|
2
main.py
2
main.py
@ -21,7 +21,7 @@ class MainGameFrame:
|
||||
self.display = pygame.display.set_mode(WINDOW_SIZE)
|
||||
agent_radius = int(TILE_WIDTH/2)
|
||||
self.agent_tex = pygame.image.load('forklift.png')
|
||||
self.warehouse_map = warehouse.Warehouse(20, 20, 150, 25)
|
||||
self.warehouse_map = warehouse.Warehouse(20, 20, 150, 2)
|
||||
starting_x, starting_y = self.set_starting_agent_position()
|
||||
self.agent = agent.Agent(starting_x, starting_y, self.warehouse_map, agent_radius)
|
||||
self.clock = pygame.time.Clock()
|
||||
|
Loading…
Reference in New Issue
Block a user