Skip to main content

henad_models/
lib.rs

1//! Example models for the Henad engine.
2//!
3//! [`example_models`] returns all ten models as a [`ModelSet`], the set that the app and the CLI offer.
4//! Each module holds one model, and the [model reference](https://micfong-z.github.io/henad/reference/models/) lists
5//! their parameters and actions.
6
7#![cfg_attr(docsrs, feature(doc_cfg))]
8#![warn(missing_docs)]
9// Proving a type that holds wgpu handles `Send` or `Sync` walks wgpu-core's registries, deeper than the default
10// limit of 128.
11#![recursion_limit = "256"]
12
13henad_compute::include_shaders!();
14
15pub mod ants;
16pub mod boids;
17pub mod game_of_life;
18pub mod gpu_ants;
19pub mod gpu_boids;
20pub mod gpu_game_of_life;
21pub mod gpu_sir;
22pub mod sir;
23pub mod team_assembly;
24pub mod virus_network;
25
26#[cfg(test)]
27mod tests;
28
29use henad_compute::entry::{
30    ModelSet, register_agent_model, register_gpu_agent_model, register_gpu_grid_model, register_grid_model,
31    register_network_model,
32};
33
34// --8<-- [start:example_models]
35/// Returns the ten example models, with henad-models' own build as their source.
36pub fn example_models() -> ModelSet {
37    let entries = [
38        register_grid_model::<crate::sir::SirGridModel>(),
39        register_agent_model::<crate::boids::BoidsModel>(),
40        register_grid_model::<crate::game_of_life::GameOfLifeModel>(),
41        register_agent_model::<crate::ants::AntsModel>(),
42        register_network_model::<crate::virus_network::VirusNetwork>(),
43        register_network_model::<crate::team_assembly::TeamAssembly>(),
44        register_gpu_grid_model::<crate::gpu_game_of_life::GpuGameOfLife>(),
45        register_gpu_grid_model::<crate::gpu_sir::GpuSir>(),
46        register_gpu_agent_model::<crate::gpu_boids::GpuBoids>(),
47        register_gpu_agent_model::<crate::gpu_ants::GpuAnts>(),
48    ];
49    let mut models = ModelSet::new(henad_core::build_info!());
50    for entry in entries {
51        // The ids are fixed above, and `every_example_model_joins_the_set` checks them.
52        models.insert(entry).expect("every example model has an id of its own");
53    }
54    models
55}
56// --8<-- [end:example_models]