From a861dfd50d34bdc7526de2f915a28401f259cb0c Mon Sep 17 00:00:00 2001 From: hamidrezakamkari Date: Tue, 4 Feb 2020 09:01:06 +0330 Subject: [PATCH] paths from player bug fixed --- AI.py | 11 +++++++++++ world.py | 13 ++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/AI.py b/AI.py index 7ce331e..1dd840e 100644 --- a/AI.py +++ b/AI.py @@ -1,6 +1,17 @@ class AI: def pick(self, world): + #self.path_to_friend_check(world) + for path in world.map.paths: + print(path) + print("----------") + + print("====================") + for path in world.get_me().paths_from_player: + print(path) + print("***") + + def path_to_friend_check(self, world): # path check: print("pick") world.choose_deck([1, 2, 3, 4]) diff --git a/world.py b/world.py index 4b2431d..63fb2d4 100644 --- a/world.py +++ b/world.py @@ -107,7 +107,8 @@ def _map_init(self, map_msg): for king in map_msg["kings"]] self.players = [Player(player_id=map_msg["kings"][i]["playerId"], king=kings[i], deck=[], - hand=[], ap=self.game_constants.max_ap, paths_from_player=[], + hand=[], ap=self.game_constants.max_ap, + paths_from_player=self._get_paths_starting_with(kings[i].center, paths), path_to_friend=self._find_path_starting_and_ending_with(kings[i].center, kings[i^1].center, paths), units=[], cast_area_spell=None, cast_unit_spell=None, duplicate_units=[], @@ -586,3 +587,13 @@ def get_game_constants(self): def get_paths_from_player(self, player_id): pass + + def _get_paths_starting_with(self, first, paths): + ret = [] + for path in paths: + c_path = Path(path = path) + if c_path.cells[-1] == first: + c_path.cells.reverse() + if c_path.cells[0] == first: + ret.append(c_path) + return ret