From add89152772952ffe3416906ef4766e4e004b089 Mon Sep 17 00:00:00 2001 From: andrzej Date: Tue, 28 Apr 2020 00:14:29 +0200 Subject: [PATCH] dddd --- agent.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/agent.py b/agent.py index df6b696..2c29443 100644 --- a/agent.py +++ b/agent.py @@ -76,13 +76,15 @@ class Agent: next = self.path.pop() self.x = next.x self.y = next.y - + def check_if_can_move(self, next_coords: Coordinates): - next_tile = self.warehouse.tiles[next_coords.x][next_coords.y] + tile_on_map = 0 <= next_coords.x < self.assigned_warehouse.width and 0 <= next_coords.y < self.assigned_warehouse.height + if not tile_on_map: + return False + next_tile = self.assigned_warehouse.tiles[next_coords.x][next_coords.y] tile_passable = isinstance(next_tile, Tile) and next_tile.category.passable - tile_on_map = 0 <= next_coords.x < self.warehouse.width and 0 <= next_coords.y < self.warehouse.height - return tile_passable and tile_on_map - + return tile_passable + def pick_up_package(self, pack): tile = pack.lays_on_field self.assigned_warehouse.tiles[tile.x_position][tile.y_position] = tile