update deps
This commit is contained in:
parent
e6cfab4a02
commit
0b3abe71ae
892
Cargo.lock
generated
892
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
10
Cargo.toml
10
Cargo.toml
@ -5,11 +5,11 @@ authors = ["Simon Gardling <titaniumtown@gmail.com>", "mindv0rtex <mindv0rtex@us
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
image = "0.23"
|
||||
indicatif = { version = "0.15", features = [ "rayon" ] }
|
||||
itertools = "0.10"
|
||||
rand = "0.8"
|
||||
rand_distr = "0.4"
|
||||
image = "0.25"
|
||||
indicatif = { version = "0.17", features = [ "rayon" ] }
|
||||
itertools = "0.14"
|
||||
rand = "0.9"
|
||||
rand_distr = "0.5"
|
||||
rayon = "1.10"
|
||||
fastapprox = "0.3"
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
use crate::{buffer::Buf, util::wrap};
|
||||
use fastapprox::faster::{cos, sin};
|
||||
use rand::{seq::SliceRandom, Rng};
|
||||
use rand::prelude::IndexedRandom;
|
||||
use rand::Rng;
|
||||
use std::f32::consts::TAU;
|
||||
use std::fmt::{Display, Formatter};
|
||||
|
||||
@ -21,7 +22,7 @@ impl Display for Agent {
|
||||
impl Agent {
|
||||
/// Construct a new agent with random parameters.
|
||||
pub fn new<R: Rng + ?Sized>(width: usize, height: usize, rng: &mut R) -> Self {
|
||||
let (x, y, angle) = rng.gen::<(f32, f32, f32)>();
|
||||
let (x, y, angle) = rng.random::<(f32, f32, f32)>();
|
||||
Agent {
|
||||
x: x * width as f32,
|
||||
y: y * height as f32,
|
||||
@ -61,7 +62,7 @@ impl Agent {
|
||||
0.0
|
||||
} else if (center < left) && (center < right) {
|
||||
*[-1.0, 1.0]
|
||||
.choose(&mut rand::thread_rng())
|
||||
.choose(&mut rand::rng())
|
||||
.expect("unable to choose random direction")
|
||||
} else if left < right {
|
||||
1.0
|
||||
|
||||
17
src/grid.rs
17
src/grid.rs
@ -1,5 +1,6 @@
|
||||
use crate::{agent::Agent, blur::Blur, buffer::Buf};
|
||||
use rand::{distributions::Uniform, Rng};
|
||||
use rand::Rng;
|
||||
use rand_distr::Uniform;
|
||||
use rayon::{iter::ParallelIterator, prelude::*};
|
||||
use std::fmt::{Display, Formatter};
|
||||
|
||||
@ -24,11 +25,11 @@ impl PopulationConfig {
|
||||
/// Construct a random configuration.
|
||||
pub fn new<R: Rng + ?Sized>(rng: &mut R) -> Self {
|
||||
PopulationConfig {
|
||||
sensor_distance: rng.gen_range(0.0..=64.0),
|
||||
step_distance: rng.gen_range(0.2..=2.0),
|
||||
sensor_angle: rng.gen_range(0.0_f32..=120.0).to_radians(),
|
||||
rotation_angle: rng.gen_range(0.0_f32..=120.0).to_radians(),
|
||||
deposition_amount: rng.gen_range(5.0..=5.0),
|
||||
sensor_distance: rng.random_range(0.0..=64.0),
|
||||
step_distance: rng.random_range(0.2..=2.0),
|
||||
sensor_angle: rng.random_range(0.0_f32..=120.0).to_radians(),
|
||||
rotation_angle: rng.random_range(0.0_f32..=120.0).to_radians(),
|
||||
deposition_amount: rng.random_range(5.0..=5.0),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -57,7 +58,7 @@ impl Grid {
|
||||
rng: &mut R,
|
||||
agents: Vec<Agent>,
|
||||
) -> Self {
|
||||
let range = Uniform::from(0.0..1.0);
|
||||
let range = Uniform::new(0.0, 1.0).expect("unable to create uniform distr");
|
||||
let data = rng.sample_iter(range).take(width * height).collect();
|
||||
|
||||
Grid {
|
||||
@ -148,7 +149,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_grid_new() {
|
||||
let mut rng = rand::thread_rng();
|
||||
let mut rng = rand::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);
|
||||
|
||||
@ -53,7 +53,7 @@ impl Model {
|
||||
let particles_per_grid = (n_particles as f64 / n_populations as f64).ceil() as usize;
|
||||
let _n_particles = particles_per_grid * n_populations;
|
||||
|
||||
let mut rng = rand::thread_rng();
|
||||
let mut rng = rand::rng();
|
||||
|
||||
let attraction_distr =
|
||||
Normal::new(Self::ATTRACTION_FACTOR_MEAN, Self::ATTRACTION_FACTOR_STD).unwrap();
|
||||
@ -111,7 +111,7 @@ impl Model {
|
||||
pub fn run(&mut self, steps: usize) {
|
||||
let pb = ProgressBar::new(steps as u64);
|
||||
pb.set_style(ProgressStyle::default_bar()
|
||||
.template("{spinner:.green} [{elapsed_precise}] [{bar:40.cyan/blue}] {pos}/{len} ({eta} {percent}%, {per_sec})")
|
||||
.template("{spinner:.green} [{elapsed_precise}] [{bar:40.cyan/blue}] {pos}/{len} ({eta} {percent}%, {per_sec})").expect("invalid progresstyle template")
|
||||
.progress_chars("#>-"));
|
||||
|
||||
for _ in 0..steps {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use rand::{seq::SliceRandom, thread_rng, Rng};
|
||||
use rand::{seq::SliceRandom, Rng};
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct Palette {
|
||||
@ -6,8 +6,8 @@ pub struct Palette {
|
||||
}
|
||||
|
||||
pub fn random_palette() -> Palette {
|
||||
let mut rng = thread_rng();
|
||||
let mut palette = PALETTES[rng.gen_range(0..PALETTES.len())];
|
||||
let mut rng = rand::rng();
|
||||
let mut palette = PALETTES[rng.random_range(0..PALETTES.len())];
|
||||
palette.colors.shuffle(&mut rng);
|
||||
palette
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user