pub struct GoBoard { /* private fields */ }
Implementations§
Source§impl GoBoard
impl GoBoard
pub fn new(size: u8, komi: Komi, rules: Rules) -> GoBoard
pub fn from_parts( rules: Rules, chains: Chains, next_player: Player, state: State, history: IntSet<Zobrist>, komi: Komi, ) -> GoBoard
pub fn size(&self) -> u8
pub fn area(&self) -> u16
pub fn rules(&self) -> Rules
pub fn komi(&self) -> Komi
pub fn chains(&self) -> &Chains
pub fn state(&self) -> State
pub fn history(&self) -> &IntSet<Zobrist>
pub fn replace_history(&mut self, history: IntSet<Zobrist>) -> IntSet<Zobrist>
pub fn clear_history(&mut self)
pub fn clone_without_history(&self) -> Self
pub fn stone_count(&self) -> u16
pub fn stone_count_from(&self, player: Player) -> u16
pub fn empty_count(&self) -> u16
pub fn stone_at(&self, tile: Tile) -> Option<Player>
pub fn empty_tiles(&self) -> impl ExactSizeIterator<Item = Tile> + '_
pub fn current_score(&self) -> Score
Sourcepub fn territory(&self) -> Vec<Territory>
pub fn territory(&self) -> Vec<Territory>
The territory map computed using Tromp-Taylor rules. The returned vec can be indexed by [FlatTile::index].
Sourcepub fn zobrist(&self) -> Zobrist
pub fn zobrist(&self) -> Zobrist
Full zobrist, including:
- the tiles
- the next player
- the pass state
pub fn random_available_place_move( &self, rng: &mut impl Rng, ) -> Result<Option<Move>, BoardDone>
pub fn assert_valid(&self)
Trait Implementations§
Source§impl Board for GoBoard
impl Board for GoBoard
Source§fn next_player(&self) -> Player
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>
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>
fn play(&mut self, mv: Self::Move) -> Result<(), PlayError>
Play the move
mv
, modifying this board.Source§fn outcome(&self) -> Option<Outcome>
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
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>
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>
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§impl<'a> BoardMoves<'a, GoBoard> for GoBoard
impl<'a> BoardMoves<'a, GoBoard> for GoBoard
type AllMovesIterator = AllMovesIterator<GoBoard>
type AvailableMovesIterator = AvailableMovesIterator<'a, GoBoard>
Source§fn all_possible_moves() -> Self::AllMovesIterator
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>
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
impl BoardSymmetry<GoBoard> for GoBoard
Source§type Symmetry = D4Symmetry
type Symmetry = D4Symmetry
The type used to represent symmetries.
Source§type CanonicalKey = Zobrist
type CanonicalKey = Zobrist
The type used by Self::canonical_key.
Source§fn map(&self, sym: D4Symmetry) -> Self
fn map(&self, sym: D4Symmetry) -> Self
Map this board under the given symmetry.
Source§fn canonical_key(&self) -> Zobrist
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
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
impl Eq for GoBoard
impl StructuralPartialEq for GoBoard
Auto Trait Implementations§
impl Freeze for GoBoard
impl RefUnwindSafe for GoBoard
impl Send for GoBoard
impl Sync for GoBoard
impl Unpin for GoBoard
impl UnwindSafe for GoBoard
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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