diff --git a/agent.py b/agent.py index 7a45721..2645586 100644 --- a/agent.py +++ b/agent.py @@ -1,5 +1,5 @@ from warehouse import Coordinates, Tile, Pack -from attributes import PackStatus +from attributes import PackStatus, TURN_LEFT_DIRECTIONS, TURN_RIGHT_DIRECTIONS class Agent: def __init__(self, start_x, start_y, assigned_warehouse, radius=5): @@ -27,6 +27,15 @@ class Agent: else: self.x = next_coords.x self.y = next_coords.y + + def turn_left(self): + new_direction = TURN_LEFT_DIRECTIONS.get(self.direction, self.direction) + self.direction = new_direction + + def turn_right(self): + new_direction = TURN_RIGHT_DIRECTIONS.get(self.direction, self.direction) + self.direction = new_direction + def move(self): next_coords = self.get_next_move_coordinates() can_move = self.check_if_can_move(next_coords) diff --git a/attributes.py b/attributes.py index 3b33a48..a3667b4 100644 --- a/attributes.py +++ b/attributes.py @@ -25,4 +25,19 @@ COLORS = { 'yellow': (235, 235, 0), 'lightgreen': (70, 238, 70), 'red': (255, 0, 0) - } \ No newline at end of file + } + + +TURN_LEFT_DIRECTIONS = { + "left": "down", + "down": "right", + "right": "up", + "up": "left" +} + +TURN_RIGHT_DIRECTIONS = { + "left": "up", + "up": "right", + "right": "down", + "down": "left" +} \ No newline at end of file