Struct GoBoard

Source
pub struct GoBoard { /* private fields */ }

Implementations§

Source§

impl GoBoard

Source

pub fn new(size: u8, komi: Komi, rules: Rules) -> GoBoard

Source

pub fn from_parts( rules: Rules, chains: Chains, next_player: Player, state: State, history: IntSet<Zobrist>, komi: Komi, ) -> GoBoard

Source

pub fn size(&self) -> u8

Source

pub fn area(&self) -> u16

Source

pub fn rules(&self) -> Rules

Source

pub fn komi(&self) -> Komi

Source

pub fn chains(&self) -> &Chains

Source

pub fn state(&self) -> State

Source

pub fn history(&self) -> &IntSet<Zobrist>

Source

pub fn replace_history(&mut self, history: IntSet<Zobrist>) -> IntSet<Zobrist>

Source

pub fn clear_history(&mut self)

Source

pub fn clone_without_history(&self) -> Self

Source

pub fn stone_count(&self) -> u16

Source

pub fn stone_count_from(&self, player: Player) -> u16

Source

pub fn empty_count(&self) -> u16

Source

pub fn stone_at(&self, tile: Tile) -> Option<Player>

Source

pub fn empty_tiles(&self) -> impl ExactSizeIterator<Item = Tile> + '_

Source

pub fn current_score(&self) -> Score

Source

pub fn territory(&self) -> Vec<Territory>

The territory map computed using Tromp-Taylor rules. The returned vec can be indexed by [FlatTile::index].

Source

pub fn zobrist(&self) -> Zobrist

Full zobrist, including:

  • the tiles
  • the next player
  • the pass state
Source

pub fn random_available_place_move( &self, rng: &mut impl Rng, ) -> Result<Option<Move>, BoardDone>

Source

pub fn assert_valid(&self)

Source§

impl GoBoard

Source

pub fn to_fen(&self) -> String

Source

pub fn from_fen(fen: &str, rules: Rules) -> Result<GoBoard, InvalidFen>

The fen format: "tiles next pass [komi]"

Trait Implementations§

Source§

impl Board for GoBoard

Source§

type Move = Move

The type used to represent moves on this board.
Source§

fn next_player(&self) -> Player

Return the next player to make a move. If the board is done this is the player that did not play the last move for consistency.
Source§

fn is_available_move(&self, mv: Self::Move) -> Result<bool, BoardDone>

Return whether the given move is available.
Source§

fn play(&mut self, mv: Self::Move) -> Result<(), PlayError>

Play the move mv, modifying this board.
Source§

fn outcome(&self) -> Option<Outcome>

The outcome of this board, is None when this games is not done yet.
Source§

fn can_lose_after_move() -> bool

Whether the player who plays a move can lose by playing that move. Symbolically whether b.won_by() == Some(Winner::Player(b.next_player())) can ever be true. This may be pessimistic, returning true is always correct.
Source§

fn random_available_move( &self, rng: &mut impl Rng, ) -> Result<Self::Move, BoardDone>

Pick a random move from the available_moves with a uniform distribution. Can be overridden for better performance.
Source§

fn clone_and_play(&self, mv: Self::Move) -> Result<Self, PlayError>

Clone this board, play mv on it and return the new board. Can be overridden for better performance.
Source§

fn is_done(&self) -> bool

Whether this games is done.
Source§

fn check_done(&self) -> Result<(), BoardDone>

Returns Read more
Source§

fn check_can_play(&self, mv: Self::Move) -> Result<(), PlayError>

Returns Read more
Source§

fn play_random_available_move( &mut self, rng: &mut impl Rng, ) -> Result<(), BoardDone>

The same as self.play(self.random_available_move(rng)), but needs less error handling. Can be overridden for better performance by skipping the valid move check.
Source§

fn children(&self) -> Result<BoardChildrenIterator<'_, Self>, BoardDone>

The same as self.available_moves().map(|mv| self.clone_and_play(mv)), but needs less error handling. Can be overridden for better performance by skipping the valid move check.
Source§

impl<'a> BoardMoves<'a, GoBoard> for GoBoard

Source§

type AllMovesIterator = AllMovesIterator<GoBoard>

Source§

type AvailableMovesIterator = AvailableMovesIterator<'a, GoBoard>

Source§

fn all_possible_moves() -> Self::AllMovesIterator

All theoretically possible moves, for any possible board. Moves returned by available_moves will always be a subset of these moves. The order of these moves does not need to match the order from available_moves.
Source§

fn available_moves(&'a self) -> Result<Self::AvailableMovesIterator, BoardDone>

Return an iterator over available moves, is always nonempty. No guarantees are made about the ordering except that it stays consistent when the board is not modified. Panics if this board is done.
Source§

impl BoardSymmetry<GoBoard> for GoBoard

Source§

type Symmetry = D4Symmetry

The type used to represent symmetries.
Source§

type CanonicalKey = Zobrist

The type used by Self::canonical_key.
Source§

fn map(&self, sym: D4Symmetry) -> Self

Map this board under the given symmetry.
Source§

fn map_move(&self, sym: D4Symmetry, mv: Move) -> Move

Map a move under the given symmetry.
Source§

fn canonical_key(&self) -> Zobrist

Extract all of the state from this board that can potentially change when calling Self::map. This is used by Self::canonicalize to determine which symmetry ends up as the canonical one for the given board.
Source§

fn canonicalize(&self) -> Self

Convert this board to a canonical version, by mapping it with the symmetry that results in the smallest Self::canonical_key. Read more
Source§

impl Clone for GoBoard

Source§

fn clone(&self) -> GoBoard

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GoBoard

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for GoBoard

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for GoBoard

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for GoBoard

Source§

fn eq(&self, other: &GoBoard) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for GoBoard

Source§

impl StructuralPartialEq for GoBoard

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V