cargo fmt
This commit is contained in:
30
src/grid.rs
30
src/grid.rs
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user