pub struct Individual {Show 17 fields
pub name: String,
pub ascension: Option<u64>,
pub environment: String,
pub population: String,
pub species: String,
pub controller: Vec<String>,
pub genome: OnceLock<Arc<[u8]>>,
pub telemetry: HashMap<String, String>,
pub epigenome: HashMap<String, String>,
pub score: Option<String>,
pub generation: u64,
pub parents: Vec<String>,
pub children: Vec<String>,
pub birth_date: String,
pub death_date: String,
pub extra: HashMap<String, Value>,
pub path: Option<PathBuf>,
}Expand description
Container for a distinct life-form and all of its associated data.
Fields§
§name: StringName or UUID of this individual.
ascension: Option<u64>Number of individuals who died before this one, or None if this individual has not yet died.
environment: StringName of the environment that this individual lives in.
population: StringName of the population that this individual belongs to.
species: StringName or UUID of this individual’s species. Mating may be restricted to individuals of the same species.
controller: Vec<String>Command line invocation of the controller program.
genome: OnceLock<Arc<[u8]>>Genetic parameters for this individual.
telemetry: HashMap<String, String>The environmental info dictionary. The environment updates this information.
epigenome: HashMap<String, String>The epigenetic info dictionary. The controller updates this information.
score: Option<String>Reproductive fitness of this individual, as assessed by the environment.
generation: u64Number of cohorts that passed before this individual was born.
parents: Vec<String>The names of this individual’s parents.
children: Vec<String>The names of this individual’s children.
birth_date: StringTime of birth, as a UTC timestamp, or an empty string if this individual has not yet been born.
death_date: StringTime of death, as a UTC timestamp, or an empty string if this individual has not yet died.
extra: HashMap<String, Value>Custom / unofficial fields that are saved with the individual.
path: Option<PathBuf>The file path this individual was loaded from or saved to, or None if this individual has not touched the file system.
Implementations§
Source§impl Individual
impl Individual
Sourcepub fn new(
environment: &str,
population: &str,
controller: &[&str],
genome: Box<[u8]>,
) -> Individual
pub fn new( environment: &str, population: &str, controller: &[&str], genome: Box<[u8]>, ) -> Individual
Create a new individual.
Sourcepub fn genome(&self) -> Arc<[u8]>
pub fn genome(&self) -> Arc<[u8]>
Get the genetic parameters for this individual. This loads the genome from file if necessary.
Sourcepub fn asex(&mut self, child_genome: &[u8]) -> Individual
pub fn asex(&mut self, child_genome: &[u8]) -> Individual
Asexually reproduce an individual.
Sourcepub fn sex(&mut self, other: &mut Individual, child_genome: &[u8]) -> Individual
pub fn sex(&mut self, other: &mut Individual, child_genome: &[u8]) -> Individual
Sexually reproduce two individuals.
Sourcepub fn save(&mut self, path: impl AsRef<Path>) -> Result<&Path, Error>
pub fn save(&mut self, path: impl AsRef<Path>) -> Result<&Path, Error>
Save an individual to a file.
Argument path is the directory to save in. Optional, use empty string for temporary file. The filename will be the individual’s name with the “.indiv” file extension.
Returns the file path of the saved individual.
Sourcepub fn load(path: impl AsRef<Path>) -> Result<Individual, Error>
pub fn load(path: impl AsRef<Path>) -> Result<Individual, Error>
Load a previously saved individual.
Trait Implementations§
Source§impl Clone for Individual
impl Clone for Individual
Source§fn clone(&self) -> Individual
fn clone(&self) -> Individual
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Individual
impl Debug for Individual
Source§impl<'de> Deserialize<'de> for Individual
impl<'de> Deserialize<'de> for Individual
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for Individual
impl PartialEq for Individual
Source§fn eq(&self, other: &Individual) -> bool
fn eq(&self, other: &Individual) -> bool
self and other values to be equal, and is used by ==.