BIG rewrite and changes (too many to list)
This commit is contained in:
18
src/grid.rs
18
src/grid.rs
@@ -4,8 +4,8 @@ use crate::{
|
||||
};
|
||||
|
||||
use rand::{distributions::Uniform, Rng};
|
||||
|
||||
use std::fmt::{Display, Formatter};
|
||||
use rayon::{iter::ParallelIterator, prelude::*};
|
||||
|
||||
// A population configuration.
|
||||
#[derive(Debug)]
|
||||
@@ -159,6 +159,22 @@ impl Grid {
|
||||
);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn tick(&mut self) {
|
||||
let self_immutable = self.clone();
|
||||
self.agents.par_iter_mut().for_each(|agent| {
|
||||
agent.tick(&self_immutable);
|
||||
});
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn deposit_all(&mut self) {
|
||||
let agent_list = self.agents.clone();
|
||||
for agent in agent_list.iter() {
|
||||
self.deposit(agent.x, agent.y);
|
||||
}
|
||||
}
|
||||
|
||||
// No longer needed (moved to imgdata.rs)
|
||||
/*
|
||||
pub fn quantile(&self, fraction: f32) -> f32 {
|
||||
|
||||
Reference in New Issue
Block a user