From 931a7d73ad3d5e3a79e033dbd75e77bdaffa74f7 Mon Sep 17 00:00:00 2001 From: Jeff Wu Date: Sat, 19 Mar 2016 15:26:41 -0700 Subject: [PATCH] percentage perfect --- src/game.rs | 2 +- src/simulator.rs | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/game.rs b/src/game.rs index 90f8210..a9c44b5 100644 --- a/src/game.rs +++ b/src/game.rs @@ -392,7 +392,7 @@ impl BoardState { // best possible value we can get for firework of that color, // based on looking at discard + fireworks - pub fn highest_attainable(&self, color: &Color) -> Value { + fn highest_attainable(&self, color: &Color) -> Value { let firework = self.fireworks.get(color).unwrap(); if firework.complete() { return FINAL_VALUE; diff --git a/src/simulator.rs b/src/simulator.rs index e4c3a07..2697907 100644 --- a/src/simulator.rs +++ b/src/simulator.rs @@ -159,14 +159,21 @@ pub fn simulate( let mut histogram = Histogram::new(); for join_handle in join_handles { let (thread_non_perfect_seeds, thread_histogram) = join_handle.join(); - info!("Thread joined"); non_perfect_seeds.extend(thread_non_perfect_seeds.iter()); histogram.merge(thread_histogram); } - non_perfect_seeds.sort(); - info!("Seeds with non-perfect score: {:?}", non_perfect_seeds); info!("Score histogram:\n{}", histogram); + + non_perfect_seeds.sort(); + // info!("Seeds with non-perfect score: {:?}", non_perfect_seeds); + if non_perfect_seeds.len() > 0 { + info!("Example seed with non-perfect score: {}", + non_perfect_seeds.get(0).unwrap().1); + } + + let percentage = (n_trials - non_perfect_seeds.len() as u32) as f32 / n_trials as f32; + info!("Percentage perfect: {:?}%", percentage); let average = histogram.average(); info!("Average score: {:?}", average); average