Skip to content

Commit

Permalink
paths from player bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
HamidrezaKmK committed Feb 4, 2020
1 parent f82ef02 commit a861dfd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
11 changes: 11 additions & 0 deletions AI.py
Original file line number Diff line number Diff line change
@@ -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])
Expand Down
13 changes: 12 additions & 1 deletion world.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[],
Expand Down Expand Up @@ -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

0 comments on commit a861dfd

Please sign in to comment.