pub struct BoidsModel;Expand description
Boids flocking as an AgentModel.
Trait Implementations§
Source§impl AgentModel for BoidsModel
impl AgentModel for BoidsModel
Source§const CHUNK: usize = 64
const CHUNK: usize = 64
Agents per chunk, smaller than the default since the kernel draws no random numbers and the population can be small. At 512, a thousand boids make two chunks and most of the pool sits idle.
Source§fn index_cell_size(params: &BoidParams) -> f32
fn index_cell_size(params: &BoidParams) -> f32
Returns a third of the visual range, so the walk covers about twice the disc it needs instead of about three times.
Source§const ID: &'static str = "boids"
const ID: &'static str = "boids"
Stable id that identifies the model in a model set, on the command line and in a spec file.
Source§const DESCRIPTION: &'static str = "A simulation of flocking behavior in a group of boids."
const DESCRIPTION: &'static str = "A simulation of flocking behavior in a group of boids."
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 = 50_000
const DEFAULT_AGENTS: u32 = 50_000
Default of
num_agents.Source§const MAX_AGENTS: u32 = 1_000_000
const MAX_AGENTS: u32 = 1_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 Index = SpatialHash
type Index = SpatialHash
Neighbour index,
SpatialHash when agents read each other and NoIndex otherwise.Source§type Params = BoidParams
type Params = BoidParams
Pre-extracted hot parameters, rebuilt once per tick.
Source§type Tally = ()
type Tally = ()
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) -> BoidParams
fn from_params(params: &[ParamValue], extent: Extent) -> BoidParams
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 init(
lanes: &mut BoidLanes,
extent: Extent,
params: &[ParamValue],
rng: &mut u64,
)
fn init( lanes: &mut BoidLanes, extent: Extent, params: &[ParamValue], rng: &mut u64, )
Fills the lanes for a new run. Read more
Source§fn run_step_pass(
lanes: &mut BoidLanes,
ctx: &StepCtx<'_, Self>,
seed: u64,
tick: u64,
)
fn run_step_pass( lanes: &mut BoidLanes, ctx: &StepCtx<'_, Self>, seed: u64, tick: u64, )
Runs the step pass and returns its tally. Read more
Source§fn act(
action: usize,
lanes: &mut BoidLanes,
_field: &mut NoField,
_extent: Extent,
params: &[ParamValue],
rng: &mut u64,
)
fn act( action: usize, lanes: &mut BoidLanes, _field: &mut NoField, _extent: Extent, params: &[ParamValue], rng: &mut u64, )
Source§fn stats(lanes: &BoidLanes, _field: &NoField, (): &()) -> Vec<StatValue>
fn stats(lanes: &BoidLanes, _field: &NoField, (): &()) -> Vec<StatValue>
Current statistics, in
Self::STATS order.Source§fn run_deposit_pass(
_lanes: &Self::Lanes,
_deposits: &mut <Self::Field as FieldLayer>::DepositLanes,
_ctx: &StepCtx<'_, Self>,
)
fn run_deposit_pass( _lanes: &Self::Lanes, _deposits: &mut <Self::Field as FieldLayer>::DepositLanes, _ctx: &StepCtx<'_, Self>, )
Fills the field’s deposit lanes before the step pass, without moving any agent. Read more
Auto Trait Implementations§
impl Freeze for BoidsModel
impl RefUnwindSafe for BoidsModel
impl Send for BoidsModel
impl Sync for BoidsModel
impl Unpin for BoidsModel
impl UnsafeUnpin for BoidsModel
impl UnwindSafe for BoidsModel
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