this isn't good
This commit is contained in:
parent
99960c9523
commit
e163387755
@ -206,13 +206,13 @@ mod tests {
|
||||
#[should_panic]
|
||||
fn test_grid_new_panics() {
|
||||
let mut rng = rand::thread_rng();
|
||||
let _ = Grid::new(5, 5, &mut rng);
|
||||
let _ = Grid::new(5, 5, &mut rng, vec![]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_grid_new() {
|
||||
let mut rng = rand::thread_rng();
|
||||
let grid = Grid::new(8, 8, &mut rng);
|
||||
let grid = Grid::new(8, 8, &mut rng, vec![]);
|
||||
assert_eq!(grid.index(0.5, 0.6), 0);
|
||||
assert_eq!(grid.index(1.5, 0.6), 1);
|
||||
assert_eq!(grid.index(0.5, 1.6), 8);
|
||||
|
||||
@ -161,14 +161,14 @@ impl Model {
|
||||
println!("Doing some population stuff...");
|
||||
let time_1 = Instant::now();
|
||||
let mut i_pop: Vec<Vec<usize>> = Vec::new();
|
||||
for i in (0..(self.grids.len())) {
|
||||
for _i in 0..(self.grids.len()) {
|
||||
i_pop.push(vec![]);
|
||||
}
|
||||
for agent in self.agents.iter() {
|
||||
i_pop[agent.population_id].push(agent.i);
|
||||
}
|
||||
|
||||
for i in (0..(self.grids.len())) {
|
||||
for i in 0..(self.grids.len()) {
|
||||
self.grids[i].i = i_pop[i].clone();
|
||||
}
|
||||
println!("Took {}ms", time_1.elapsed().as_millis());
|
||||
@ -244,7 +244,7 @@ impl Model {
|
||||
if use_exp_deposit {
|
||||
let agent_list = self.agents.clone();
|
||||
self.grids.par_iter_mut().for_each(|grid|{
|
||||
for i in (0..grid.i.len()) {
|
||||
for i in 0..grid.i.len() {
|
||||
let agent = &agent_list[i];
|
||||
grid.deposit(agent.x, agent.y);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user