pub struct AntsModel;Expand description
Ant foraging, ported from krABMaga’s antsforaging.
A comparison with the reference has to state three differences. Deposits combine with max
instead of the last writer winning. Every pheromone read sees the old field, and every write goes to the new
field. The RNG is seeded per chunk per tick instead of drawn per call.
The reference’s biased neighbour tie-break is reproduced as it is (see step::advect_agent).
Trait Implementations§
Source§impl AgentModel for AntsModel
impl AgentModel for AntsModel
Source§const CHUNK: usize = 4096
const CHUNK: usize = 4096
Agents per chunk. The movement draws are seeded per chunk, so another value gives other results.
Source§fn init(
lanes: &mut AntLanes,
extent: Extent,
params: &[ParamValue],
_rng: &mut u64,
)
fn init( lanes: &mut AntLanes, extent: Extent, params: &[ParamValue], _rng: &mut u64, )
Ants start holding reward so they lay home pheromone immediately and the colony has a
gradient to navigate back along.
Source§const ID: &'static str = "ants"
const ID: &'static str = "ants"
Stable id that identifies the model in a model set, on the command line and in a spec file.
Source§const DESCRIPTION: &'static str = "Ants lay and follow pheromone trails between a nest and a food source, around obstacles"
const DESCRIPTION: &'static str = "Ants lay and follow pheromone trails between a nest and a food source, around obstacles"
One-line description shown in the UI.
Source§const STATS: &'static [StatDescriptor]
const STATS: &'static [StatDescriptor]
Stat series for the history chart. Declared once, so
stats returns bare values.Source§const ACTIONS: &'static [ActionDescriptor] = ACTION_SPECS
const ACTIONS: &'static [ActionDescriptor] = ACTION_SPECS
One-off steps the user can trigger. Each gets a button in the Parameters panel.
Source§const DEFAULT_AGENTS: u32 = 2_000
const DEFAULT_AGENTS: u32 = 2_000
Default of
num_agents.Source§const MAX_AGENTS: u32 = 5_000_000
const MAX_AGENTS: u32 = 5_000_000
Upper bound of
num_agents.Source§const DEFAULT_EXTENT: Extent
const DEFAULT_EXTENT: Extent
Defaults of
world_width and world_height.Source§type Field = ScalarField<PheromoneField>
type Field = ScalarField<PheromoneField>
Grid layer under the population, or
NoField for a model
without a field.Source§type Index = NoIndex
type Index = NoIndex
Neighbour index,
SpatialHash when agents read each other and NoIndex otherwise.Source§type Tally = u64
type Tally = u64
Per chunk reduction, accumulated across ticks.
() when there is nothing to count. Read moreSource§fn param_descriptors() -> Vec<ParamDescriptor>
fn param_descriptors() -> Vec<ParamDescriptor>
Model parameters.
num_agents, world_width and world_height are prepended by the
engine at indices 0, 1 and 2.Source§fn from_params(params: &[ParamValue], extent: Extent) -> AntParams
fn from_params(params: &[ParamValue], extent: Extent) -> AntParams
Extracts the hot parameters for one tick.
params is this model’s own slice, so its
indices are 0 based and cannot shift when the engine or a field layer changes.Source§fn run_deposit_pass(
lanes: &AntLanes,
deposits: &mut Deposits,
ctx: &StepCtx<'_, Self>,
)
fn run_deposit_pass( lanes: &AntLanes, deposits: &mut Deposits, ctx: &StepCtx<'_, Self>, )
Fills the field’s deposit lanes before the step pass, without moving any agent. Read more
Source§fn run_step_pass(
lanes: &mut AntLanes,
ctx: &StepCtx<'_, Self>,
seed: u64,
tick: u64,
) -> u64
fn run_step_pass( lanes: &mut AntLanes, ctx: &StepCtx<'_, Self>, seed: u64, tick: u64, ) -> u64
Runs the step pass and returns its tally. Read more
Source§fn act(
action: usize,
lanes: &mut AntLanes,
field: &mut ScalarField<PheromoneField>,
extent: Extent,
params: &[ParamValue],
rng: &mut u64,
)
fn act( action: usize, lanes: &mut AntLanes, field: &mut ScalarField<PheromoneField>, extent: Extent, params: &[ParamValue], rng: &mut u64, )
Source§fn stats(
lanes: &AntLanes,
field: &ScalarField<PheromoneField>,
tally: &u64,
) -> Vec<StatValue>
fn stats( lanes: &AntLanes, field: &ScalarField<PheromoneField>, tally: &u64, ) -> Vec<StatValue>
Current statistics, in
Self::STATS order.Auto Trait Implementations§
impl Freeze for AntsModel
impl RefUnwindSafe for AntsModel
impl Send for AntsModel
impl Sync for AntsModel
impl Unpin for AntsModel
impl UnsafeUnpin for AntsModel
impl UnwindSafe for AntsModel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more