package uulm.teamname.marvelous.gamelibrary.ai; import java.util.ArrayList; import java.util.List; public class Node { public final Board board; public final Action action; public final Float score; private final List children = new ArrayList<>(); private Node parent = null; public Node(Board board, Action action) { this.board = board; this.action = action; this.score = 0f; } public Node(Board board, Action action, Float score) { this.board = board; this.action = action; this.score = score; } public void addChild(Node child) { child.setParent(this); this.children.add(child); } public void addChild(Board board, Action action) { this.addChild(new Node(board, action)); } public void addChild(Board board, Action action, Float score) { this.addChild(new Node(board, action, score)); } public void addChildren(List children) { for(Node t : children) { t.setParent(this); } this.children.addAll(children); } public List getChildren() { return children; } public boolean hasChildren() { return !children.isEmpty(); } private void setParent(Node parent) { this.parent = parent; } public Node getParent() { return parent; } }