pub struct Match { /* private fields */ }Expand description
§Backgammon Match
A match is a series of games played until a player reaches the predefined number of points.
§Recommended Use for AI Agents
When implementing an agent, always call Match::get_board() to retrieve the board state, but commit moves back through the Match interface to ensure the doubling cube and score are updated.
AI Agent Setup: Always define the match context first
use backgammon::prelude::*;
fn setup_agent_environment() -> Match {
let mut m = Match::new();
m.set_points(13).unwrap();
m.set_crawford(true).unwrap();
m
}Implementations§
Source§impl Match
Implements methods for the Match struct
impl Match
Implements methods for the Match struct
Sourcepub fn offer_double(&mut self, player: Player) -> Result<(), Error>
pub fn offer_double(&mut self, player: Player) -> Result<(), Error>
Offer the cube to the other player.
Sourcepub fn accept_double(&mut self, player: Player) -> Result<(), Error>
pub fn accept_double(&mut self, player: Player) -> Result<(), Error>
After a double has been offered, the other player can accept it.
Sourcepub fn reject_double(&mut self, player: Player) -> Result<(), Error>
pub fn reject_double(&mut self, player: Player) -> Result<(), Error>
After a double has been offered, the other player can reject it.
Sourcepub fn get_match_state(&self) -> Result<&MatchState, Error>
pub fn get_match_state(&self) -> Result<&MatchState, Error>
Return the current state of the match.
Sourcepub fn get_game_state(&self) -> Result<&GameState, Error>
pub fn get_game_state(&self) -> Result<&GameState, Error>
Return the current state of the actual match’s game.
Sourcepub fn get_player(&self) -> Result<Player, Error>
pub fn get_player(&self) -> Result<Player, Error>
Return the current player, i.e. the player who needs to perform an action.
Sourcepub fn get_score(&self) -> Result<(u64, u64), Error>
pub fn get_score(&self) -> Result<(u64, u64), Error>
Return the current score of the match (player 0, player 1).
Sourcepub fn get_cube_value(&self) -> Result<u64, Error>
pub fn get_cube_value(&self) -> Result<u64, Error>
Return the current cube value.
Sourcepub fn get_cube_owner(&self) -> Result<Player, Error>
pub fn get_cube_owner(&self) -> Result<Player, Error>
Return the current cube owner.