Class RolloutSearch<S,A>

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

public class RolloutSearch<S,A> extends Object
Generic branch-local rollout search for mutable game-state problems.

Unlike Simulation, this search does not merge candidates by coordinate. Each branch carries its own state, which makes it suitable for combat prediction where NPC positions, attack cooldowns, or projectiles differ depending on the exact actions taken earlier in the branch.

  • Constructor Details

    • RolloutSearch

      public RolloutSearch(RolloutOptions options, Function<S,? extends Collection<A>> actions, BiFunction<S,A,S> transition, ToIntFunction<RolloutNode<S,A>> evaluator, Predicate<RolloutNode<S,A>> terminal)
      Creates a rollout search.
      Parameters:
      options - search limits
      actions - supplies legal actions for a state
      transition - applies an action and returns the next branch state
      evaluator - scores a branch node
      terminal - returns whether a branch should stop expanding
  • Method Details

    • create

      public static <S, A> RolloutSearch.Builder<S,A> create(RolloutOptions options)
      Starts a rollout search builder.
      Type Parameters:
      S - simulated state type
      A - action type
      Parameters:
      options - search limits
    • run

      public Optional<RolloutResult<S,A>> run(S initial)
      Runs the search from an initial state.
      Parameters:
      initial - initial simulated state
      Returns:
      selected branch, or empty when the root has no actions