Crate npc_engine_core

Source
Expand description

This is the core of the NPC engine, containing the MCTS algorithm implementation and related abstractions.

We provide several examples as introductions on how to use the planner. A good place to start is tic-tac-toe.

The core of the planner is the MCTS struct, which holds the state of the planner. It has two constructors, a simplified one, new, and a complete one, new_with_tasks. Once constructed, the run method performs the search and returns the best task. After a search, the resulting tree can be inspected, starting from the root node.

The MCTS struct is generic over a Domain, which you have to implement to describe your own planning domain. You need to implement at least these three methods:

The graphviz feature enables to output the search tree in the Graphviz’s dot format using the plot_mcts_tree function.

Additional features and utilites such as execution loops are available in the npc-engine-utils crate. You might want to use them in your project as they make the planner significantly simpler to use. Most examples use them.

Macros§

impl_task_boxed_methods
Task implementors can use this macro to implement the box_clone, box_hash and box_eq functions.

Structs§

ActiveTask
A task associated to an agent and that is being processed by the planner.
AgentId
The identifier of an agent, essentially a u32.
DefaultPolicyEstimator
MCTS default policy using simulation-based rollout.
EdgeInner
The data associated with an edge.
Edges
The outgoing edges from a node, possibly partially expanded.
IdleTask
An idle task of duration 1 that is used by the planner when the task of an agent is not known.
MCTS
The state of a running planner instance.
MCTSConfiguration
The configuration of an MCTS instance.
NodeInner
The data associated to a node that form its key.
PlanningTask
A task to represent planning in the planning tree, if these need to be represented.
StateDiffRef
A joint reference to an initial state and a difference to this state.
StateDiffRefMut
A joint reference to an initial state and a difference to this state, where the difference is mutable.

Traits§

Behavior
A possibly-recursive set of possible tasks.
Domain
A domain on which the MCTS planner can plan.
DomainWithPlanningTask
Domains who want to use planning tasks must implement this.
StateValueEstimator
An estimator of state-value function.
Task
A task that modifies the state.

Functions§

debug_name_to_filename_safe
Transforms the debug string of a task to a string that can safely be used for filenames.

Type Aliases§

ActiveTasks
A set of active tasks.
AgentValue
The “current” value an agent has in a given state.
EarlyStopCondition
A functor that returns whether the planner must do an early stop.
Edge
Strong atomic reference counted edge.
Node
Strong atomic reference counted node.
TaskDuration
The duration of a task, in ticks.
WeakNode
Weak atomic reference counted node.