From c36278ec2593ff9b25bf3f5bad22ab547cca5447 Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Thu, 16 Aug 2018 22:58:07 +0200 Subject: Printed debug for different tower building --- src/strategy/monte_carlo.rs | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) (limited to 'src/strategy/monte_carlo.rs') diff --git a/src/strategy/monte_carlo.rs b/src/strategy/monte_carlo.rs index a2b5a4b..f937ea1 100644 --- a/src/strategy/monte_carlo.rs +++ b/src/strategy/monte_carlo.rs @@ -1,6 +1,7 @@ use engine::command::*; use engine::status::GameStatus; use engine::bitwise_engine::{Player, BitwiseGameState}; +use engine::geometry::*; use engine::constants::*; use std::fmt; @@ -37,14 +38,52 @@ pub fn choose_move(state: &BitwiseGameState, start_time: PreciseTime, max_time: } #[cfg(feature = "debug-decisions")] { - for score in command_scores { - println!("{}", score); - } + debug_print_choices("ENERGY", &command_scores, |score| match score.command { + Command::Build(p, BuildingType::Energy) => Some((p, score.win_ratio())), + _ => None + }); + debug_print_choices("ATTACK", &command_scores, |score| match score.command { + Command::Build(p, BuildingType::Attack) => Some((p, score.win_ratio())), + _ => None + }); + debug_print_choices("DEFENCE", &command_scores, |score| match score.command { + Command::Build(p, BuildingType::Defence) => Some((p, score.win_ratio())), + _ => None + }); + debug_print_choices("TESLA", &command_scores, |score| match score.command { + Command::Build(p, BuildingType::Tesla) => Some((p, score.win_ratio())), + _ => None + }); + + println!("NOTHING"); + println!("{}", command_scores.iter().find(|c| c.command == Command::Nothing).map(|s| s.win_ratio()).unwrap_or(0)); + println!(""); + + println!("IRON CURTAIN"); + println!("{}", command_scores.iter().find(|c| c.command == Command::IronCurtain).map(|s| s.win_ratio()).unwrap_or(0)); + println!(""); } command } +#[cfg(feature = "debug-decisions")] +fn debug_print_choices Option<(Point, i32)>>(label: &str, command_scores: &[CommandScore], extractor: F) { + println!("{}", label); + let relevant_moves: Vec<(Point, i32)> = command_scores.iter() + .filter_map(extractor) + .collect(); + for y in 0..MAP_HEIGHT { + for x in 0..SINGLE_MAP_WIDTH { + let point = Point::new(x, y); + let score = relevant_moves.iter().find(|(p, _)| *p == point); + print!(" | {}", score.map(|(_,s)| s).cloned().unwrap_or(0)); + } + println!(" |"); + } + println!(""); +} + #[cfg(not(feature = "discard-poor-performers"))] fn simulate_options_to_timeout(command_scores: &'a mut Vec, settings: &GameSettings, state: &BitwiseGameState, start_time: PreciseTime, max_time: Duration) -> Option<&'a CommandScore> { loop { -- cgit v1.2.3