Class RolloutNode<S,A>

java.lang.Object
dev.twilite.game.simulation.rollout.RolloutNode<S,A>
Type Parameters:
S - simulated state type
A - action type

public class RolloutNode<S,A> extends Object
Mutable search-tree node for one rollout branch.
  • Constructor Summary

    Constructors
    Constructor
    Description
    RolloutNode(RolloutNode<S,A> parent, S state, A action, int depth)
    Creates a rollout node.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the action that produced this node.
    Returns actions from the root to this node.
    void
    Adds a child node.
    double
    Returns this node's average score.
    Returns child nodes already expanded from this node.
    int
    Returns the number of actions from the root to this node.
    boolean
    Returns whether this node has already generated its children.
    void
    expanded(boolean expanded)
    Marks this node as expanded.
    Returns the first action from the root to this node.
    Returns the previous node in the branch.
    void
    record(int score)
    Records one score sample for this node.
    Returns the simulated state at this node.
    int
    Returns the sum of all scores back-propagated through this node.
    int
    Returns the number of times this node has been evaluated or passed through during search.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RolloutNode

      public RolloutNode(RolloutNode<S,A> parent, S state, A action, int depth)
      Creates a rollout node.
      Parameters:
      parent - previous node in the branch, or null for the root
      state - state after applying action
      action - action that produced this node, or null for the root
      depth - branch depth
  • Method Details

    • parent

      public Optional<RolloutNode<S,A>> parent()
      Returns the previous node in the branch.
    • state

      public S state()
      Returns the simulated state at this node.
    • action

      public Optional<A> action()
      Returns the action that produced this node.
    • depth

      public int depth()
      Returns the number of actions from the root to this node.
    • children

      public List<RolloutNode<S,A>> 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

      public List<A> actions()
      Returns actions from the root to this node.
    • firstAction

      public Optional<A> firstAction()
      Returns the first action from the root to this node.
    • addChild

      public void addChild(RolloutNode<S,A> child)
      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