2022-04-08 00:43:25 +02:00
|
|
|
from typing import Tuple
|
|
|
|
|
|
|
|
from mesa import Agent
|
|
|
|
|
2022-04-16 14:55:25 +02:00
|
|
|
from AgentBase import AgentBase
|
2022-04-08 00:43:25 +02:00
|
|
|
from data.Direction import Direction
|
2022-04-16 14:55:25 +02:00
|
|
|
from util.AgentIdFactory import AgentIdFactory
|
2022-03-06 22:16:21 +01:00
|
|
|
|
|
|
|
|
2022-04-16 14:55:25 +02:00
|
|
|
class ForkliftAgent(AgentBase):
|
2022-03-06 22:16:21 +01:00
|
|
|
|
2022-04-16 14:55:25 +02:00
|
|
|
def __init__(self, model):
|
|
|
|
super().__init__(model)
|
2022-04-16 15:55:43 +02:00
|
|
|
# self.movement_queue = [Tuple[int, int]]
|
|
|
|
# self.current_position = Tuple[int, int]
|
2022-04-08 00:43:25 +02:00
|
|
|
self.current_rotation = Direction.right
|
|
|
|
|
2022-04-16 15:55:43 +02:00
|
|
|
# def assign_new_movement_task(self, movement_list):
|
|
|
|
# self.movement_queue = []
|
|
|
|
#
|
|
|
|
# for m in movement_list:
|
|
|
|
# self.movement_queue.append(m)
|
|
|
|
#
|
|
|
|
# print("Assigned new movement queue to forklift agent")
|
|
|
|
#
|
|
|
|
# def get_proper_rotation(self, next_pos: Tuple[int, int]) -> Direction:
|
|
|
|
#
|
|
|
|
# if next_pos[0] < self.current_position[0]:
|
|
|
|
# return Direction.left
|
|
|
|
# elif next_pos[0] > self.current_position[0]:
|
|
|
|
# return Direction.right
|
|
|
|
# elif next_pos[1] > self.current_position[1]:
|
|
|
|
# return Direction.top
|
|
|
|
# elif next_pos[1] < self.current_position[1]:
|
|
|
|
# return Direction.down
|
|
|
|
# elif next_pos == self.current_position:
|
|
|
|
# return self.current_rotation
|
|
|
|
#
|
|
|
|
# def move(self):
|
|
|
|
# if len(self.movement_queue) > 0:
|
|
|
|
# next_pos = self.movement_queue.pop(0)
|
|
|
|
#
|
|
|
|
# dir = self.get_proper_rotation(next_pos)
|
|
|
|
#
|
|
|
|
# if dir == self.current_rotation:
|
|
|
|
# print("move {} --> {}".format(self.current_position, next_pos))
|
|
|
|
# self.current_position = next_pos
|
|
|
|
# else:
|
|
|
|
# print("rotate {} --> {}".format(self.current_rotation, dir))
|
|
|
|
# self.current_rotation = dir
|
|
|
|
# self.movement_queue.insert(0, next_pos)
|
|
|
|
#
|
|
|
|
# def step(self) -> None:
|
|
|
|
# print("forklift step")
|
|
|
|
# self.move()
|
2022-04-16 14:55:25 +02:00
|
|
|
|
|
|
|
def creation_log(self):
|
|
|
|
print("Created Forklift Agent [id: {}]".format(self.unique_id))
|