|
@ -37,8 +37,8 @@ state: State |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Member: |
|
|
class Member: |
|
|
def __init__(self, field: Field, team: int, id: int): |
|
|
def __init__(self, field: Field, team: int, id: int) -> None: |
|
|
self.field = field, |
|
|
self.field = field |
|
|
self.team = team |
|
|
self.team = team |
|
|
self.id = id |
|
|
self.id = id |
|
|
self.action = Action.STAY |
|
|
self.action = Action.STAY |
|
@ -49,7 +49,7 @@ class Field: |
|
|
|
|
|
|
|
|
def __init__(self, i: int, j: int, hill: bool, |
|
|
def __init__(self, i: int, j: int, hill: bool, |
|
|
home_for_team: Optional[int], |
|
|
home_for_team: Optional[int], |
|
|
occupied_by_team: Optional[int]): |
|
|
occupied_by_team: Optional[int]) -> None: |
|
|
self.i = i |
|
|
self.i = i |
|
|
self.j = j |
|
|
self.j = j |
|
|
self.hill = hill |
|
|
self.hill = hill |
|
@ -79,7 +79,7 @@ class Field: |
|
|
neighbour_i = self.i |
|
|
neighbour_i = self.i |
|
|
neighbour_j = self.j |
|
|
neighbour_j = self.j |
|
|
# ensure coords are in bounds |
|
|
# ensure coords are in bounds |
|
|
neighbour_i %= len(state.world), |
|
|
neighbour_i %= len(state.world) |
|
|
neighbour_j %= len(state.world[0]) |
|
|
neighbour_j %= len(state.world[0]) |
|
|
return state.world[neighbour_i][neighbour_j] |
|
|
return state.world[neighbour_i][neighbour_j] |
|
|
|
|
|
|
|
@ -147,10 +147,10 @@ def pathfind(member: Member, goal: Field) -> Action: |
|
|
if (neighbour in explored or |
|
|
if (neighbour in explored or |
|
|
not neighbour.is_accessible(member.team)): |
|
|
not neighbour.is_accessible(member.team)): |
|
|
continue |
|
|
continue |
|
|
if field == member.field: |
|
|
if neighbour == member.field: |
|
|
return action.invert() |
|
|
return action.invert() |
|
|
queue.append(neighbour) |
|
|
queue.append(neighbour) |
|
|
explored.add(field) |
|
|
explored.add(neighbour) |
|
|
return Action.STAY |
|
|
return Action.STAY |
|
|
|
|
|
|
|
|
|
|
|
|
|
|