From 3d9f957c4f9abe5c070441bd1bbafa3e733c954c Mon Sep 17 00:00:00 2001 From: Andy Killorin <37423245+Speedy6451@users.noreply.github.com> Date: Mon, 9 Nov 2026 15:04:16 -0500 Subject: [PATCH] multi-run --- simulator/src/main.rs | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/simulator/src/main.rs b/simulator/src/main.rs index e9f27d2..8af789f 100644 --- a/simulator/src/main.rs +++ b/simulator/src/main.rs @@ -109,12 +109,7 @@ impl Food { } } - -#[macroquad::main("Adversarial Foraging Simulator")] -async fn main() { - - rand::srand(4); - +async fn run_simulation() -> (i32, i32) { let mut robots = Vec::new(); let mut score = HashMap::new(); @@ -196,5 +191,34 @@ async fn main() { if rendered { next_frame().await // TODO: framerate cap } + + if food.is_empty() { + let red = score.get(&color_hash(RED)).unwrap_or(&0); + let blu = score.get(&color_hash(BLUE)).unwrap_or(&0); + return (*red, *blu); + } } } + + +#[macroquad::main("Adversarial Foraging Simulator")] +async fn main() { + + let mut rtot = 0; + let mut btot = 0; + for i in 0..100 { + rand::srand(i); + + let (red, blu) = run_simulation().await; + + rtot += red; + btot += blu; + + println!("{} wins! RED: {red}, BLU: {blu}", if red > blu {"red"} else {"blue"}); + } + + let red = rtot / 100; + let blu = btot / 100; + println!("{} wins on average! RED: {red}, BLU: {blu}", if red > blu {"red"} else {"blue"}); + +}