From 019b3c86bead4a415953e8496939350298dccb5c Mon Sep 17 00:00:00 2001 From: korzepadawid Date: Mon, 11 Apr 2022 20:04:53 +0200 Subject: [PATCH] feat: expand and child node --- algorithms/a_star.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/algorithms/a_star.py b/algorithms/a_star.py index c593f69..c18872d 100644 --- a/algorithms/a_star.py +++ b/algorithms/a_star.py @@ -45,11 +45,16 @@ class Node: return hash(self.state) -def child_node(action: Action) -> Node: - pass +def expand(node: Node) -> List[Node]: + return [child_node(node=node, action=action) for action in actions(node.state)] -def actions(state: State) -> List[str]: +def child_node(node: Node, action: Action) -> Node: + next_state = result(state=node.state, action=action) + return Node(state=next_state, parent=node, action=action) + + +def actions(state: State) -> List[Action]: pass