summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin Worthe <justin@worthe-it.co.za>2018-08-31 21:43:58 +0200
committerJustin Worthe <justin@worthe-it.co.za>2018-08-31 21:43:58 +0200
commit82230e9f67dbebb3a0a608a53bca05aa38a5f501 (patch)
treebbf7085f0e85cbdbdb9dd89ccdf0711ae5d1fbb1 /src
parent18510603042a7c55b512cdba41fea6c1e84854df (diff)
Placeholder for new heuristic based random search
Diffstat (limited to 'src')
-rw-r--r--src/strategy/monte_carlo.rs17
1 files changed, 15 insertions, 2 deletions
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<R: Rng>(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<R: Rng>(player: &Player, rng: &mut R) -> Command {
+ Command::Nothing
+}
+
+#[cfg(not(feature = "heuristic-random"))]
fn random_move<R: Rng>(player: &Player, rng: &mut R) -> Command {
let free_positions_count = player.unoccupied_cell_count();