From 82230e9f67dbebb3a0a608a53bca05aa38a5f501 Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Fri, 31 Aug 2018 21:43:58 +0200 Subject: Placeholder for new heuristic based random search --- src/strategy/monte_carlo.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/strategy/monte_carlo.rs') diff --git a/src/strategy/monte_carlo.rs b/src/strategy/monte_carlo.rs index 6176f1a..2489c8a 100644 --- a/src/strategy/monte_carlo.rs +++ b/src/strategy/monte_carlo.rs @@ -168,8 +168,21 @@ fn simulate_to_endstate(command_score: &mut CommandScore, state: &Bitwis } } -// TODO: This needs a decent heuristic play. Don't do nothing and -// target certain rows with missiles? +// TODO +// 1. Have a (static) array of all moves. Even invalid ones. ALL +// 2. Create a new CDF array, same size. +// 3. Loop moves +// 3.1. Compute PDF for move. Invalid moves are 0. +// 3.2. Add to last CDF value and stick in array +// 4. Generate random number uniformly, 0 to CDF max +// 5. Binary search to find random number in CDF array. Min index where CDF[index] > random +// 6. Lookup move in static array +#[cfg(feature = "heuristic-random")] +fn random_move(player: &Player, rng: &mut R) -> Command { + Command::Nothing +} + +#[cfg(not(feature = "heuristic-random"))] fn random_move(player: &Player, rng: &mut R) -> Command { let free_positions_count = player.unoccupied_cell_count(); -- cgit v1.2.3