summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin Worthe <justin@worthe-it.co.za>2018-08-16 22:22:31 +0200
committerJustin Worthe <justin@worthe-it.co.za>2018-08-16 22:22:31 +0200
commitc2795dd5bd74f9bdc1c77ae5a07b2b416a71d714 (patch)
tree2490c85568244988a8c68f5e261aa60beb8a7bdb /src
parentbaa4f9950f49ffbb451c4796a764738f48b29504 (diff)
Added initial seed on nothing move
Diffstat (limited to 'src')
-rw-r--r--src/strategy/monte_carlo.rs18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/strategy/monte_carlo.rs b/src/strategy/monte_carlo.rs
index ba2ef5c..a2b5a4b 100644
--- a/src/strategy/monte_carlo.rs
+++ b/src/strategy/monte_carlo.rs
@@ -8,6 +8,7 @@ use std::fmt;
use rand::{Rng, XorShiftRng, SeedableRng};
const MAX_MOVES: u16 = 400;
+const INIT_SEED: [u8;16] = [0x7b, 0x6a, 0xe1, 0xf4, 0x41, 0x3c, 0xe9, 0x0f, 0x67, 0x81, 0x67, 0x99, 0x77, 0x0a, 0x6b, 0xda];
use time::{Duration, PreciseTime};
@@ -162,7 +163,19 @@ impl CommandScore {
draws: 0,
stalemates: 0,
attempts: 0,
- next_seed: [0x7b, 0x6a, 0xe1, 0xf4, 0x41, 0x3c, 0xe9, 0x0f, 0x67, 0x81, 0x67, 0x99, 0x77, 0x0a, 0x6b, 0xda]
+ next_seed: INIT_SEED
+ }
+ }
+
+ fn with_seeded_stalemate(command: Command) -> CommandScore {
+ CommandScore {
+ command,
+ victories: 0,
+ defeats: 0,
+ draws: 0,
+ stalemates: 0,
+ attempts: 1,
+ next_seed: INIT_SEED
}
}
@@ -194,7 +207,6 @@ impl CommandScore {
(self.victories as i32 - self.defeats as i32) * 10000 / (self.attempts as i32)
}
- //TODO: Devalue nothing so that it doesn't stand and do nothing when it can do things
fn init_command_scores(state: &BitwiseGameState) -> Vec<CommandScore> {
let all_buildings = sensible_buildings(&state.player);
@@ -203,7 +215,7 @@ impl CommandScore {
let building_command_count = unoccupied_cells.len()*all_buildings.len();
let mut commands = Vec::with_capacity(building_command_count + 2);
- commands.push(CommandScore::new(Command::Nothing));
+ commands.push(CommandScore::with_seeded_stalemate(Command::Nothing));
if state.player.can_build_iron_curtain() {
commands.push(CommandScore::new(Command::IronCurtain));
}