pub trait Behavior<D: Domain>: 'static {
// Required methods
fn is_valid(
&self,
tick: u64,
state: StateDiffRef<'_, D>,
agent: AgentId,
) -> bool;
fn add_own_tasks(
&self,
tick: u64,
state: StateDiffRef<'_, D>,
agent: AgentId,
tasks: &mut Vec<Box<dyn Task<D>>>,
);
// Provided methods
fn get_dependent_behaviors(&self) -> &'static [&'static dyn Behavior<D>] { ... }
fn add_tasks(
&self,
tick: u64,
state: StateDiffRef<'_, D>,
agent: AgentId,
tasks: &mut Vec<Box<dyn Task<D>>>,
) { ... }
}
Expand description
A possibly-recursive set of possible tasks.
You need to implement at least two methods: is_valid and add_own_tasks.
Required Methods§
Sourcefn is_valid(
&self,
tick: u64,
state: StateDiffRef<'_, D>,
agent: AgentId,
) -> bool
fn is_valid( &self, tick: u64, state: StateDiffRef<'_, D>, agent: AgentId, ) -> bool
Returns if the behavior is valid for the given agent in the given world state.
Sourcefn add_own_tasks(
&self,
tick: u64,
state: StateDiffRef<'_, D>,
agent: AgentId,
tasks: &mut Vec<Box<dyn Task<D>>>,
)
fn add_own_tasks( &self, tick: u64, state: StateDiffRef<'_, D>, agent: AgentId, tasks: &mut Vec<Box<dyn Task<D>>>, )
Collects valid tasks for the given agent in the given world state.
Provided Methods§
Sourcefn get_dependent_behaviors(&self) -> &'static [&'static dyn Behavior<D>]
fn get_dependent_behaviors(&self) -> &'static [&'static dyn Behavior<D>]
Returns dependent behaviors.