multi-run
This commit is contained in:
parent
bd9412e54a
commit
3d9f957c4f
1 changed files with 30 additions and 6 deletions
|
|
@ -109,12 +109,7 @@ impl Food {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn run_simulation() -> (i32, i32) {
|
||||||
#[macroquad::main("Adversarial Foraging Simulator")]
|
|
||||||
async fn main() {
|
|
||||||
|
|
||||||
rand::srand(4);
|
|
||||||
|
|
||||||
let mut robots = Vec::new();
|
let mut robots = Vec::new();
|
||||||
|
|
||||||
let mut score = HashMap::new();
|
let mut score = HashMap::new();
|
||||||
|
|
@ -196,5 +191,34 @@ async fn main() {
|
||||||
if rendered {
|
if rendered {
|
||||||
next_frame().await // TODO: framerate cap
|
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"});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue