diff options
Diffstat (limited to 'src/strategy.rs')
-rw-r--r-- | src/strategy.rs | 46 |
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) |