summaryrefslogtreecommitdiff
path: root/src/strategy.rs
diff options
context:
space:
mode:
authorJustin Worthe <justin@worthe-it.co.za>2019-06-29 10:52:18 +0200
committerJustin Worthe <justin@worthe-it.co.za>2019-06-29 10:52:18 +0200
commit886d7f75bca7078799074f0b4e7b80c6f8081f5f (patch)
tree47e9463043bbc7118d8be494fad2340da6c6dc11 /src/strategy.rs
parentd5070033892a531fab75ae1951deeb25c2d5f741 (diff)
Put score allocation behind constants
Diffstat (limited to 'src/strategy.rs')
-rw-r--r--src/strategy.rs42
1 files changed, 23 insertions, 19 deletions
diff --git a/src/strategy.rs b/src/strategy.rs
index 771dccf..036a620 100644
--- a/src/strategy.rs
+++ b/src/strategy.rs
@@ -202,27 +202,31 @@ fn score(state: &GameBoard) -> Score {
}
fn rollout(state: &GameBoard) -> Score {
- let mut s = state.clone();
- let mut rng = rand::thread_rng();
- while s.outcome == SimulationOutcome::Continue {
- let player_moves = rollout_moves(&s, 0);
- let opponent_moves = rollout_moves(&s, 1);
-
- s.simulate([
- player_moves
- .choose(&mut rng)
- .cloned()
- .unwrap_or_else(|| Command::new(Action::DoNothing)),
- opponent_moves
- .choose(&mut rng)
- .cloned()
- .unwrap_or_else(|| Command::new(Action::DoNothing)),
- ]);
- }
-
- score(&s)
+ score(state)
}
+// fn rollout(state: &GameBoard) -> Score {
+// let mut s = state.clone();
+// let mut rng = rand::thread_rng();
+// while s.outcome == SimulationOutcome::Continue {
+// let player_moves = rollout_moves(&s, 0);
+// let opponent_moves = rollout_moves(&s, 1);
+
+// s.simulate([
+// player_moves
+// .choose(&mut rng)
+// .cloned()
+// .unwrap_or_else(|| Command::new(Action::DoNothing)),
+// opponent_moves
+// .choose(&mut rng)
+// .cloned()
+// .unwrap_or_else(|| Command::new(Action::DoNothing)),
+// ]);
+// }
+
+// score(&s)
+// }
+
fn choose_existing(node: &Node) -> [Command; 2] {
[choose_one_existing(node, 0), choose_one_existing(node, 1)]
}