cargo fmt

This commit is contained in:
2025-03-24 16:27:11 -04:00
parent 3a9940dfba
commit f0d4e883f6
7 changed files with 313 additions and 86 deletions

View File

@@ -1,12 +1,8 @@
use crate::{
blur::Blur,
agent::Agent,
buffer::Buf,
};
use crate::{agent::Agent, blur::Blur, buffer::Buf};
use rand::{distributions::Uniform, Rng};
use std::fmt::{Display, Formatter};
use rayon::{iter::ParallelIterator, prelude::*};
use std::fmt::{Display, Formatter};
// A population configuration.
#[derive(Debug)]
@@ -93,7 +89,7 @@ pub struct Grid {
// pub buf: Vec<f32>,
pub buf: Buf,
pub blur: Blur,
pub agents: Vec<Agent>
pub agents: Vec<Agent>,
}
impl Clone for Grid {
@@ -112,7 +108,12 @@ impl Clone for Grid {
impl Grid {
// Create a new grid filled with random floats in the [0.0..1.0) range.
pub fn new<R: Rng + ?Sized>(width: usize, height: usize, rng: &mut R, agents: Vec<Agent>) -> Self {
pub fn new<R: Rng + ?Sized>(
width: usize,
height: usize,
rng: &mut R,
agents: Vec<Agent>,
) -> Self {
if !width.is_power_of_two() || !height.is_power_of_two() {
panic!("Grid dimensions must be a power of two.");
}
@@ -177,10 +178,15 @@ impl Grid {
let buf = self.buf.clone();
self.agents.par_iter_mut().for_each(|agent| {
agent.tick(&buf,
sensor_distance, sensor_angle,
rotation_angle, step_distance,
width, height);
agent.tick(
&buf,
sensor_distance,
sensor_angle,
rotation_angle,
step_distance,
width,
height,
);
});
self.deposit_all();
}