mod search;
mod builder;
use std::fmt::Debug;
use std::fmt::Display;
use serde::Serialize;
type HashMap<K,V> = rustc_hash::FxHashMap<K,V>;
type Rng = rand_xorshift::XorShiftRng;
pub trait Action: Copy + Clone + Debug {}
pub trait Player: Copy + Clone + Debug + PartialEq {}
#[derive(Debug)]
pub enum GameResult {Win,Lose,Draw}
pub trait GameState<P: Player, A: Action>: Copy + Debug + Display {
fn actions<F>(&self,f: &mut F) where F: FnMut(A);
fn make(&self,action: A) -> Self;
fn gameover(&self) -> Option<GameResult>;
fn player(&self) -> P;
fn hash(&self) -> u64 {0}
fn custom_evaluation(&self) -> f32 {0.5}
}
#[derive(Debug)]
enum Node<P: Player, A: Action> {
Unknown(bool,A),
Terminal(bool,A,P,f32),
Leaf(bool,A,P,f32,u32),
Branch(bool,A,P,f32,u32,usize),
Transpose(bool,A,usize),
}
#[derive(Default,Debug,Serialize,Copy,Clone)]
pub struct Info {
pub q: f32,
pub n: u32,
pub branch: u32,
pub leaf: u32,
pub terminal: u32,
pub unknown: u32,
pub transpose: u32,
pub bytes: usize,
}
pub struct MCTS<P: Player, A: Action, S: GameState<P,A>> {
exploration: f32,
expansion: u32,
use_custom_evaluation: bool,
use_transposition: bool,
pub info: Info,
root: S,
stack: Vec<Node<P,A>>,
actions: Vec<A>,
rand: Rng,
map: HashMap<u64,usize>,
}