From ee3dbaf8365ed1638a2e4ef2139f8e0478e9b4e6 Mon Sep 17 00:00:00 2001 From: Juergen Stuber Date: Sun, 22 Oct 2023 10:31:23 +0200 Subject: [PATCH] Add randomness to the initial conditions --- src/bin/lorenz/main.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/bin/lorenz/main.rs b/src/bin/lorenz/main.rs index 68718e7..03a11d1 100644 --- a/src/bin/lorenz/main.rs +++ b/src/bin/lorenz/main.rs @@ -5,6 +5,9 @@ use std::iter::repeat; use std::thread::sleep; use std::time::Duration; +use rand::thread_rng; +use rand::Rng; + use pixelfoo::color::Color; type Frame = Vec>; @@ -28,6 +31,8 @@ fn main() -> std::io::Result<()> { let arg = args[3].parse::().unwrap_or(DEFAULT_ARG); eprintln!("screen size {}x{}, arg {}", x_size, y_size, arg); + let mut rng = thread_rng(); + let t_frame = 0.040; // s let delay = Duration::new(0, (1_000_000_000.0 * t_frame) as u32); @@ -56,7 +61,7 @@ fn main() -> std::io::Result<()> { let b = 27.0; let c = 8.0 / 3.0; - let mut x = 1.0; + let mut x = rng.gen::() - 0.5; let mut y = 0.0; let mut z = zc;