|
|
@ -36,13 +36,15 @@ class Team: |
|
|
|
home: Field |
|
|
|
|
|
|
|
def __init__(self, id: int, is_me: bool) -> None: |
|
|
|
self.id: int = id |
|
|
|
self.id = id |
|
|
|
self.is_me = is_me |
|
|
|
self.protected_fields: List[Field] = [] |
|
|
|
self.occupied: List[Field] = [] |
|
|
|
self.members: List[Member] = [] |
|
|
|
|
|
|
|
def __eq__(self, other: Field) -> bool: |
|
|
|
def __eq__(self, other: object) -> bool: |
|
|
|
if not isinstance(other, Team): |
|
|
|
return NotImplemented |
|
|
|
return (self.id) == (other.id) |
|
|
|
|
|
|
|
def __hash__(self) -> int: |
|
|
@ -50,7 +52,7 @@ class Team: |
|
|
|
|
|
|
|
|
|
|
|
class Member: |
|
|
|
def __init__(self, field: Field, team: int, id: int) -> None: |
|
|
|
def __init__(self, field: Field, team: Team, id: int) -> None: |
|
|
|
self.field = field |
|
|
|
self.team = team |
|
|
|
self.id = id |
|
|
@ -64,14 +66,16 @@ class Field: |
|
|
|
home_for_team: Optional[Team], |
|
|
|
occupied_by_team: Optional[Team], |
|
|
|
protected_for_team: Optional[Team],) -> None: |
|
|
|
self.i: int = i |
|
|
|
self.j: int = j |
|
|
|
self.hill: bool = hill |
|
|
|
self.i = i |
|
|
|
self.j = j |
|
|
|
self.hill = hill |
|
|
|
self.home_for_team: Optional[Team] = home_for_team |
|
|
|
self.occupied_by_team: Optional[Team] = occupied_by_team |
|
|
|
self.protected_for_team: Optional[Team] = protected_for_team |
|
|
|
|
|
|
|
def __eq__(self, other: Field) -> bool: |
|
|
|
def __eq__(self, other: object) -> bool: |
|
|
|
if not isinstance(other, Field): |
|
|
|
return NotImplemented |
|
|
|
return (self.i, self.j) == (other.i, other.j) |
|
|
|
|
|
|
|
def __hash__(self) -> int: |
|
|
@ -126,7 +130,7 @@ class State: |
|
|
|
self.time_to_response: Optional[int] = state["time_to_response"] |
|
|
|
|
|
|
|
def _parse_world(self, world: dict) -> List[List[Field]]: |
|
|
|
def get_team(team_id): |
|
|
|
def get_team(team_id: int) -> Optional[Team]: |
|
|
|
return None if team_id is None else self.teams[team_id] |
|
|
|
|
|
|
|
fields = [] |
|
|
@ -148,13 +152,14 @@ class State: |
|
|
|
parsed_field.protected_for_team.protected_fields.append(parsed_field) |
|
|
|
members = [] |
|
|
|
for member in field["members"]: |
|
|
|
member_team = self.teams[member["team_id"]] |
|
|
|
m = Member( |
|
|
|
parsed_field, |
|
|
|
self.teams[member["team"]], |
|
|
|
member_team, |
|
|
|
member["id"], |
|
|
|
) |
|
|
|
members.append(m) |
|
|
|
m.team.members.append(m) |
|
|
|
member_team.members.append(m) |
|
|
|
parsed_field.members = members |
|
|
|
fields_row.append(parsed_field) |
|
|
|
|
|
|
@ -227,7 +232,7 @@ def main() -> None: |
|
|
|
|
|
|
|
# TODO: zde doplňte svou herní strategii |
|
|
|
# příklad: všechny vojáky posílám nahoru |
|
|
|
for member in state.teams[state.my_team].members: |
|
|
|
for member in state.my_team.members: |
|
|
|
member.action = Direction.UP |
|
|
|
|
|
|
|
print(json.dumps(state.build_turn())) |
|
|
|