summaryrefslogtreecommitdiff
path: root/src/strategy.rs
diff options
context:
space:
mode:
authorJustin Worthe <justin@worthe-it.co.za>2019-07-07 12:10:42 +0200
committerJustin Worthe <justin@worthe-it.co.za>2019-07-07 12:10:42 +0200
commit352ad4a297511dfe843bad5206879983ad34f3e2 (patch)
tree5e77aa34ea23b9080eaee4885ff1129c4249aec8 /src/strategy.rs
parentd385199c48d565d9ffc8948f137d716e534d5d0d (diff)
Cleaned up dead code
Diffstat (limited to 'src/strategy.rs')
-rw-r--r--src/strategy.rs46
1 files changed, 1 insertions, 45 deletions
diff --git a/src/strategy.rs b/src/strategy.rs
index 036a620..0c86eeb 100644
--- a/src/strategy.rs
+++ b/src/strategy.rs
@@ -6,13 +6,10 @@ use std::collections::HashMap;
use std::ops::*;
use time::{Duration, PreciseTime};
-use rand;
-use rand::prelude::*;
-
pub fn choose_move(
state: &GameBoard,
previous_root: Option<Node>,
- start_time: &PreciseTime,
+ start_time: PreciseTime,
max_time: Duration,
) -> (Command, Node) {
let mut root_node = match previous_root {
@@ -205,28 +202,6 @@ fn rollout(state: &GameBoard) -> Score {
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)]
}
@@ -255,25 +230,6 @@ fn update(node: &mut Node, commands: [Command; 2], score: Score) {
node.score_sum += score;
}
-fn rollout_moves(state: &GameBoard, player_index: usize) -> Vec<Command> {
- // TODO: Have this return one move, chosen randomly?
- // TODO: Heuristic based move
- valid_moves(state, player_index)
- //
- // if let Some(worm) = state.players[player_index].active_worm() {
-
- // let shoots = state.sensible_shoot_commands(player_index, worm.position, worm.weapon_range);
-
- // if !shoots.is_empty() {
- // return shoots.into_iter().collect();
- // }
-
- // state.valid_move_commands(player_index).into_iter().collect()
- // } else {
- // [Command::new(Action::DoNothing)].into_iter().cloned().collect()
- // }
-}
-
fn valid_moves(state: &GameBoard, player_index: usize) -> Vec<Command> {
state
.valid_shoot_commands(player_index)