Update main.py

This commit is contained in:
Miron 2021-05-09 23:01:08 +02:00
parent 9f24b128eb
commit 0529f89343

View File

@ -29,9 +29,9 @@ WAREHOUSE_MAP = [
[0, 10, 0, 0, 0, 200, 200, 200, 200], [0, 10, 0, 0, 0, 200, 200, 200, 200],
[0, 0, 10, 0, 0, 0, 0, 0, 0], [0, 0, 10, 0, 0, 0, 0, 0, 0],
[0, 0, 10, 0, 0, 200, 200, 200, 200], [0, 0, 10, 0, 0, 200, 200, 200, 200],
[0, 0, 10, 0, 0, 0, 0, 0, 0], [0, 0, 10, 10, 0, 0, 0, 0, 0],
[10, 0, 0, 0, 0, 200, 200, 200, 200], [10, 0, 0, 0, 10, 200, 200, 200, 200],
[0, 0, 0, 10, 0, 0, 0, 0, 0], [0, 0, 10, 10, 10, 0, 0, 0, 0],
[0, 10, 0, 0, 0, 200, 200, 200, 200], [0, 10, 0, 0, 0, 200, 200, 200, 200],
] ]
@ -319,7 +319,7 @@ class Stain:
class Agent: class Agent:
def __init__(self, pos, agent_direction="right"): def __init__(self, pos, agent_direction="right"):
self.pos = pos self.pos = pos
self.pos_coord = (get_position_from_pix(pos)[1], get_position_from_pix(pos)[0]) self.pos_coord = get_position_from_pix(pos)
self.image = IMAGE self.image = IMAGE
self.rect = self.image.get_rect(center=pos) self.rect = self.image.get_rect(center=pos)
self.goal = (0, 0) self.goal = (0, 0)
@ -443,7 +443,7 @@ Package_list = [
print(a_star_search((6, 8), (0, 0), "down")) print(a_star_search((6, 8), (0, 0), "down"))
#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, (0, 0), agent.agent_direction) agent.path = a_star_search((agent.pos_coord[1], agent.pos_coord[0]), (0, 0), agent.agent_direction)
print(agent.path) print(agent.path)
@ -497,8 +497,8 @@ while running:
agent.goal = coord_goals.pop(0) agent.goal = coord_goals.pop(0)
agent.goal_achieved = False agent.goal_achieved = False
#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, agent.goal, 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)
# DRAWING # DRAWING
screen.blit(BACKGROUND, [0, 0]) screen.blit(BACKGROUND, [0, 0])