from __future__ import annotations from dataclasses import dataclass, field from enum import Enum, unique from typing import Tuple, Optional, List @unique class Direction(Enum): LEFT = (0, -1) RIGHT = (0, 1) UP = (-1, 0) DOWN = (1, 0) @unique class Action(Enum): TURN_LEFT = 'TURN_LEFT' TURN_RIGHT = 'TURN_RIGHT' FORWARD = 'FORWARD' @dataclass class State: position: Tuple[int, int] direction: Direction @dataclass class Node: state: State parent: Optional[Node] action: Action cost: int = field(init=False) depth: int = field(init=False) def __post_init__(self) -> None: self.cost = 0 if not self.parent else self.parent.cost + 1 self.depth = self.cost def __eq__(self, other: Node) -> bool: return self.state == other.state def __hash__(self) -> int: return hash(self.state) def child_node(action: Action) -> Node: pass def actions(state: State) -> List[str]: pass def result(state: State, action: Action) -> State: pass def goal_test(state: State, goal_list: List[Tuple[int, int]]) -> bool: pass def h(state: State) -> int: pass def f(state: State) -> int: pass