Skip to content

Commit

Permalink
Beautify map in python client debug method
Browse files Browse the repository at this point in the history
  • Loading branch information
mhmdrz-mirdamadi committed Sep 5, 2022
1 parent 70a1ee6 commit 57e0b71
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Clients/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ def __init__(self) -> None:
self.data: int
self.coordinates: tuple(int, int)

def __str__(self) -> str:
res = self.type.name
if self.type in [MapType.OUT_OF_SIGHT, MapType.OUT_OF_MAP]:
return res.center(16)
elif self.type in [MapType.AGENT, MapType.GOLD]:
res += f':{self.data}'
res += f' ({self.coordinates[0]},{self.coordinates[1]})'
return res.center(16)


class Map:
def __init__(self) -> None:
Expand All @@ -51,6 +60,15 @@ def __init__(self) -> None:
self.sight_range: int
self.grid: list

def __str__(self) -> str:
res = f'sight range -> {self.sight_range}\n'
for i in range(self.sight_range):
res += '\t'
for j in range(self.sight_range):
res += str(self.grid[i * self.sight_range + j])
res += '*' if j < 4 else '\n'
return res[:-1]

def set_grid_size(self) -> None:
self.grid = [MapTile() for _ in range(self.sight_range ** 2)]

Expand All @@ -74,6 +92,7 @@ def set_info(self) -> None:
self.location = tuple(map(int, input().split())) # (row, column)
for tile in self.map.grid:
tile.type, tile.data, *tile.coordinates = map(int, input().split())
tile.type = MapType(tile.type)
self.agent_id = int(input()) # player1: 0,1 --- player2: 2,3
self.current_round = int(input()) # 1 indexed
self.attack_ratio = float(input())
Expand All @@ -88,6 +107,7 @@ def debug(self) -> None:
# Customize to your needs
self.debug_log += f'round: {str(self.current_round)}\n'
self.debug_log += f'location: {str(self.location)}\n'
self.debug_log += f'Map: {str(self.map)}\n'
self.debug_log += f'attack ratio: {str(self.attack_ratio)}\n'
self.debug_log += f'defence level: {str(self.deflvl)}\n'
self.debug_log += f'attack level: {str(self.atklvl)}\n'
Expand Down

0 comments on commit 57e0b71

Please sign in to comment.