From c6a7a3154b7ba59f3abc7581b35dd460023cc8f9 Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Wed, 16 May 2018 00:01:27 +0200 Subject: Moved away from special benchmarking suite Just using normal monte carlo. More iterations -> better. --- src/strategy/monte_carlo.rs | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'src/strategy') diff --git a/src/strategy/monte_carlo.rs b/src/strategy/monte_carlo.rs index b7025c5..fe0462f 100644 --- a/src/strategy/monte_carlo.rs +++ b/src/strategy/monte_carlo.rs @@ -8,19 +8,29 @@ const MAX_MOVES: u16 = 400; use time::{Duration, PreciseTime}; +#[cfg(not(feature = "single-threaded"))] use rayon::prelude::*; pub fn choose_move(settings: &GameSettings, state: &GameState, start_time: &PreciseTime, max_time: Duration) -> Command { - println!("Using MONTE_CARLO strategy"); - let mut command_scores = CommandScore::init_command_scores(settings, state); loop { - command_scores.par_iter_mut() - .for_each(|score| { - let mut rng = thread_rng(); - simulate_to_endstate(score, settings, state, &mut rng); - }); + #[cfg(feature = "single-threaded")] + { + command_scores.iter_mut() + .for_each(|score| { + let mut rng = thread_rng(); + simulate_to_endstate(score, settings, state, &mut rng); + }); + } + #[cfg(not(feature = "single-threaded"))] + { + command_scores.par_iter_mut() + .for_each(|score| { + let mut rng = thread_rng(); + simulate_to_endstate(score, settings, state, &mut rng); + }); + } if start_time.to(PreciseTime::now()) > max_time { break; } -- cgit v1.2.3