[][src]Struct goban::rules::game::Game

pub struct Game { /* fields omitted */ }

Most important struct of the library, it's the entry point. It represents a Game of Go.

Implementations

impl Game[src]

pub fn goban(&self) -> &Goban[src]

pub fn last_hash(&self) -> &u64[src]

impl Game[src]

pub fn passes(&self) -> u8[src]

pub fn prisoners(&self) -> (u32, u32)[src]

pub fn turn(&self) -> Player[src]

pub fn komi(&self) -> f32[src]

pub fn rule(&self) -> Rule[src]

pub fn handicap(&self) -> u8[src]

impl Game[src]

pub fn set_komi(&mut self, val: f32) -> &mut Self[src]

pub fn set_rule(&mut self, val: Rule) -> &mut Self[src]

impl Game[src]

pub fn new(size: GobanSizes, rule: Rule) -> Self[src]

Crates a new game for playing Go

impl Game[src]

pub fn resume(&mut self)[src]

Resume the game when to players have passed, and want to continue.

pub fn is_over(&self) -> bool[src]

True when the game is over (two passes, or no more legals moves, Resign)

pub fn outcome(&self) -> Option<EndGame>[src]

Returns the endgame. None if the game is not finished

pub fn pseudo_legals(&self) -> impl Iterator<Item = Point> + '_[src]

Generate all moves on all empty intersections.

pub fn legals(&self) -> impl Iterator<Item = Point> + '_[src]

Returns a list with legals moves. from the rule specified in at the creation.

pub fn legals_by(
    &self,
    legals_rules: IllegalRules
) -> impl Iterator<Item = Point> + '_
[src]

Return a list with the legals moves. doesn't take the rule specified in the game but take the one passed on parameter.

pub fn play(&mut self, play: Move) -> &mut Self[src]

Method to play on the goban or pass. (0,0) is in the top left corner of the goban.

Panics

If the coordinates of the move are outside the board.

pub fn play_for_verification(&self, (x, y): Point) -> u64[src]

This methods plays a move then return the hash of the goban simulated, used in legals for fast move simulation in Super Ko situations.

pub fn try_play(&mut self, play: Move) -> Result<&mut Self, PlayError>[src]

Method to play but it verifies if the play is legal or not.

Errors

If the move is a suicide Move return SuicideMove If the move is a Ko Move returns Ko If the game is paused then return GamePaused

pub fn put_handicap(&mut self, points: &[Point])[src]

Put the handicap stones on the goban. This put the turn for white but doesn't update the komi.

pub fn calculate_score(&self) -> (f32, f32)[src]

Calculates score. with prisoners and komi. Dependant of the rule in the game.

pub fn calculate_score_by(&self, rule: ScoreRules) -> (f32, f32)[src]

Calculates the score by the rule passed in parameter.

pub fn will_capture(&self, point: Point) -> bool[src]

Returns true if the stone played in that point will capture another string.

pub fn check_point(&self, point: Point) -> Option<PlayError>[src]

Test if a point is legal or not for the current player,

pub fn check_point_by(
    &self,
    point: Point,
    illegal_rules: IllegalRules
) -> Option<PlayError>
[src]

Test if a point is legal or not by the rule passed in parameter.

pub fn check_eye(
    &self,
    Stone { coordinates: point, color: color }: Stone
) -> bool
[src]

Detects true eyes. return true is the stone is an eye. Except for this form :

 ++
 + ++
 ++ +
   ++

This function is only used for performance checking in the rules, and not for checking is a point is really an eye !

pub fn check_ko(&self, stone: Stone) -> bool[src]

Test if a play is ko. If the goban is in the configuration of two plays ago returns true

pub fn check_superko(&self, stone: Stone) -> bool[src]

Rule of the super Ko, if any before configuration was already played then return true.

pub fn check_suicide(&self, stone: Stone) -> bool[src]

Add a stone to the board an then test if the stone or stone group is dead. Returns true if the move is a suicide

pub fn display_goban(&self)[src]

Displays the internal board.

impl Game[src]

impl Game[src]

pub fn from_sgf(sgf_str: &str) -> Result<Self, String>[src]

Trait Implementations

impl Clone for Game[src]

impl Debug for Game[src]

impl Default for Game[src]

Auto Trait Implementations

impl !RefUnwindSafe for Game

impl !Send for Game

impl !Sync for Game

impl Unpin for Game

impl UnwindSafe for Game

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,