1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
use crate::Algorithm; use crate::Move; use std::fmt; pub mod fox_and_hounds; pub mod noughts_and_crosses; pub trait Game: Clone + fmt::Debug { type Move: Move; const SCORE_MAX: i32 = 2_000_000_000; const SCORE_MIN: i32 = -2_000_000_000; fn possible_moves(&self) -> Vec<Self::Move>; fn execute_move(&self, mov: Self::Move) -> Self; fn do_move(&mut self, mov: Self::Move) -> Self::Move; fn undo_move(&mut self, mov: Self::Move); fn get_score(&self) -> i32; fn score_if_win_next_round(&self) -> i32; fn is_game_over(&self) -> bool; fn calculate_move<T: Algorithm>( &self, depth: i32, do_precalculated_moves: bool, ) -> Option<Self::Move>; }