BIG rewrite and changes (too many to list)

This commit is contained in:
Simon Gardling
2021-04-01 11:24:29 -04:00
parent dc2e46c51b
commit 4864ccae75
6 changed files with 42 additions and 30 deletions

View File

@@ -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 {