Class RolloutNode<S,A>
java.lang.Object
dev.twilite.game.simulation.rollout.RolloutNode<S,A>
- Type Parameters:
S- simulated state typeA- action type
Mutable search-tree node for one rollout branch.
-
Constructor Summary
ConstructorsConstructorDescriptionRolloutNode(RolloutNode<S, A> parent, S state, A action, int depth) Creates a rollout node. -
Method Summary
Modifier and TypeMethodDescriptionaction()Returns the action that produced this node.actions()Returns actions from the root to this node.voidaddChild(RolloutNode<S, A> child) Adds a child node.doubleReturns this node's average score.List<RolloutNode<S, A>> children()Returns child nodes already expanded from this node.intdepth()Returns the number of actions from the root to this node.booleanexpanded()Returns whether this node has already generated its children.voidexpanded(boolean expanded) Marks this node as expanded.Returns the first action from the root to this node.parent()Returns the previous node in the branch.voidrecord(int score) Records one score sample for this node.state()Returns the simulated state at this node.intReturns the sum of all scores back-propagated through this node.intvisits()Returns the number of times this node has been evaluated or passed through during search.
-
Constructor Details
-
RolloutNode
Creates a rollout node.- Parameters:
parent- previous node in the branch, ornullfor the rootstate- state after applyingactionaction- action that produced this node, ornullfor the rootdepth- branch depth
-
-
Method Details
-
parent
Returns the previous node in the branch. -
state
Returns the simulated state at this node. -
action
Returns the action that produced this node. -
depth
public int depth()Returns the number of actions from the root to this node. -
children
Returns child nodes already expanded from this node. -
expanded
public boolean expanded()Returns whether this node has already generated its children. -
visits
public int visits()Returns the number of times this node has been evaluated or passed through during search. -
totalScore
public int totalScore()Returns the sum of all scores back-propagated through this node. -
averageScore
public double averageScore()Returns this node's average score. -
actions
Returns actions from the root to this node. -
firstAction
Returns the first action from the root to this node. -
addChild
Adds a child node.- Parameters:
child- child node
-
expanded
public void expanded(boolean expanded) Marks this node as expanded. -
record
public void record(int score) Records one score sample for this node.- Parameters:
score- score to add
-