diff --git a/bfs.py b/bfs.py index 12c09f4..a1cc10a 100644 --- a/bfs.py +++ b/bfs.py @@ -9,10 +9,12 @@ from turnCar import turn_left_orientation, turn_right_orientation class Succ: state: AgentState action: AgentActionType + cost: int def __init__(self, state: AgentState, action: AgentActionType) -> None: self.state = state self.action = action + self.cost = cost def find_path_to_nearest_can(startState: AgentState, grid: Dict[Tuple[int, int], GridCellType]) -> list[AgentActionType]: q: Queue[list[Succ]] = Queue() @@ -88,6 +90,12 @@ def is_state_success(state: AgentState, grid: Dict[Tuple[int, int], GridCellType except: return False +def get_cost_for_cell_type(cell_type: GridCellType) -> int: + if cell_type == GridCellType.SPEED_BUMP: + return 10 + else: + return 1 + def is_state_valid(state: AgentState, grid: Dict[Tuple[int, int], GridCellType]) -> bool: try: return grid[state.position] == GridCellType.STREET_HORIZONTAL or grid[state.position] == GridCellType.STREET_VERTICAL or grid[state.position] == GridCellType.SPEED_BUMP diff --git a/city.py b/city.py index 74e7483..2cd1a1f 100644 --- a/city.py +++ b/city.py @@ -2,19 +2,7 @@ from typing import List from garbageCan import GarbageCan from speedBump import SpeedBump from street import Street -from gameContext import GameContext - -class Node: - garbageCan: GarbageCan - speedBump: SpeedBump - id: int - - def __init__(self, id: int, can: GarbageCan, bump: SpeedBump) -> None: - self.id - self.can = can - self.bump = bump - - +from gameContext import GameContext class City: nodes: List[GarbageCan]