Class RolloutSearch<S,A>
java.lang.Object
dev.twilite.game.simulation.rollout.RolloutSearch<S,A>
- Type Parameters:
S- simulated state typeA- action type
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordBuilder step after legal actions are known.static final recordBuilder for a rollout search.static final recordFinal builder step for optional terminal configuration and construction.static final recordBuilder step after actions and transition are known. -
Constructor Summary
ConstructorsConstructorDescriptionRolloutSearch(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. -
Method Summary
Modifier and TypeMethodDescriptionstatic <S,A> RolloutSearch.Builder <S, A> create(RolloutOptions options) Starts a rollout search builder.Runs the search from an initial state.
-
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 limitsactions- supplies legal actions for a statetransition- applies an action and returns the next branch stateevaluator- scores a branch nodeterminal- returns whether a branch should stop expanding
-
-
Method Details
-
create
Starts a rollout search builder.- Type Parameters:
S- simulated state typeA- action type- Parameters:
options- search limits
-
run
Runs the search from an initial state.- Parameters:
initial- initial simulated state- Returns:
- selected branch, or empty when the root has no actions
-