cleanup and comments

This commit is contained in:
Simon Gardling 2021-03-29 14:01:04 +00:00
parent 611dd03acf
commit 59d060261d
3 changed files with 20 additions and 22 deletions

View File

@ -1,6 +1,6 @@
use crate::{
grid::{combine, Grid, PopulationConfig},
palette::{random_palette, Palette},
grid::{Grid},
palette::{Palette},
};

View File

@ -1,34 +1,32 @@
use indicatif::{ProgressBar, ProgressStyle};
use physarum::model;
use rand::Rng;
fn main() {
// let n_iterations = 16384;
let n_iterations = 10;
// let n_iterations = 100;
// let n_iterations = 10;
// # of iterations to go through
let n_iterations = 1024;
// Size of grid and pictures
let (width, height) = (256, 256);
// let (width, height) = (512, 512);
// let (width, height) = (1024, 1024);
// let (width, height) = (2048, 2048);
// # of agents
let n_particles = 1 << 22;
// let n_particles = 1 << 10;
// let n_particles = 1 << 20;
// let n_particles = 100;
println!("n_particles: {}", n_particles);
let diffusivity = 1;
let mut rng = rand::thread_rng();
// let n_populations = 1 + rng.gen_range(1..4);
// `n_populations` is the # of types of agents
let n_populations = 2;
let mut model = model::Model::new(width, height, n_particles, n_populations, diffusivity);
model.print_configurations();
model.run(n_iterations);
// let n_populations = 1 + rng.gen_range(1..4); // make # of populations between 2 and 5
let mut model = model::Model::new(width, height, n_particles, n_populations, diffusivity); // Create the model
model.print_configurations(); // Print config for model
model.run(n_iterations); // Actually run the model
// export saved image data
println!("Rendering all saved image data....");
model.render_all_imgdata();
model.flush_image_data();

View File

@ -9,8 +9,8 @@ use rand_distr::{Distribution, Normal};
use rayon::prelude::*;
use itertools::multizip;
use std::f32::consts::TAU;
use std::time::{Duration, Instant};
use rayon::iter::{ParallelIterator, IntoParallelIterator};
use std::time::{Instant};
use rayon::iter::{ParallelIterator,};
use indicatif::{ParallelProgressIterator, ProgressBar, ProgressStyle};
use std::path::Path;
@ -191,7 +191,7 @@ impl Model {
combine(grids, &self.attraction_table);
let agents_tick_time = Instant::now();
self.agents.par_iter_mut().for_each(|agent| {
let i: usize = agent.i;
// let i: usize = agent.i;
let grid = &grids[agent.population_id];
let (width, height) = (grid.width, grid.height);