mocats 0.3.0

A fast, easy-to-use, generalized Monte Carlo Tree Search library. Works for any game, any number of players, and any tree policy (UCT Policy included as a default).
Documentation
//! Contains the traits that define a game.

use std::fmt::{Debug, Display};


/// Represents a game state.
pub trait GameState<A: GameAction, P: Player> : Clone {
    /// Returns the actions that can be taken from this state.
    fn get_actions(&self) -> Vec<A>;
    /// Applies the given action to this state.
    fn apply_action(&mut self, action: &A);
    /// Returns the player whose turn it is.
    fn get_turn(&self) -> P;
    /// Returns whether the game is over.
    fn get_reward_for_player(&self, player: P) -> f32;
}

/// Represents a legal game action that can be applied to some GameState.
pub trait GameAction: Debug+PartialEq+Copy+Display {}

/// Represents a player in a game. Should be an enum.
pub trait Player: Debug+Eq+Copy {}