This commit is contained in:
2025-03-27 14:22:06 -04:00
parent 9881502002
commit 75fab93907
3 changed files with 10 additions and 65 deletions

View File

@@ -1,5 +1,4 @@
use crate::{buffer::Buf, util::wrap};
use fastapprox::faster::{cos, sin};
use rand::{seq::SliceRandom, Rng};
use std::f32::consts::TAU;
@@ -41,7 +40,6 @@ impl Agent {
}
// Tick an agent
#[inline]
pub fn tick(
&mut self,
buf: &Buf,
@@ -75,7 +73,9 @@ impl Agent {
if (center > left) && (center > right) {
direction = 0.0;
} else if (center < left) && (center < right) {
direction = *[-1.0, 1.0].choose(&mut rng).unwrap();
direction = *[-1.0, 1.0]
.choose(&mut rng)
.expect("unable to choose random direction");
} else if left < right {
direction = 1.0;
} else if right < left {