[][src]Struct goban::pieces::goban::Goban

pub struct Goban { /* fields omitted */ }

Represents a Goban. the stones are stored in ROW MAJOR (row, colum)

Implementations

impl Goban[src]

impl Goban[src]

pub fn size(&self) -> (usize, usize)[src]

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

impl Goban[src]

pub fn new((height, width): (u8, u8)) -> Self[src]

Creates a Goban

Arguments

  • (height, width) a tuple with the height and the width of the desired goban.

pub fn from_array(stones: &[Color]) -> Self[src]

Creates a Goban from an array of stones.

pub fn raw(&self) -> Vec<Color>[src]

Returns the underlying goban in a vector with a RowMajor Policy

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

Get number of stones on the goban. (number of black stones, number of white stones)

pub fn push(&mut self, point: Point, color: Color) -> &mut Self[src]

Put a stones in the goban. The point depends on the order choose. default (line, column) the (0,0) point is in the top left.

Panics

if the point is out of bounds

pub fn push_stone(&mut self, stone: Stone) -> &mut Goban[src]

Helper function to put a stone.

pub fn push_many(&mut self, points: &[Point], value: Color)[src]

Put many stones.

pub fn get_neighbors(&self, coord: Point) -> impl Iterator<Item = Stone> + '_[src]

Get all the neighbors to the coordinate including empty intersections.

pub fn get_neighbors_stones(
    &self,
    coord: Point
) -> impl Iterator<Item = Stone> + '_
[src]

Get all the stones that are neighbor to the coord except empty intersections.

pub fn get_neighbors_strings(
    &self,
    coord: Point
) -> impl Iterator<Item = ByAddress<Rc<GoString>>> + '_
[src]

Get all the neighbors go strings to the point. Only return point with a color.

pub fn get_neighbors_strings_index(
    &self,
    index: usize
) -> impl Iterator<Item = ByAddress<Rc<GoString>>> + '_
[src]

pub fn get_stone(&self, point: Point) -> Color[src]

Function for getting the stone in the goban.

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

Get all the stones except "Empty stones"

pub fn get_stones_by_color(
    &self,
    color: Color
) -> impl Iterator<Item = Stone> + '_
[src]

Get stones by their color.

pub fn get_points_by_color(&self, color: Color) -> impl Iterator<Item = Point>[src]

Get points by their color.

pub fn get_liberties(&self, point: Point) -> impl Iterator<Item = Stone> + '_[src]

Returns the empty stones connected to the stone

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

Returns true if the stone has liberties.

pub fn pretty_string(&self) -> String[src]

Get a string for printing the goban in normal shape (0,0) left bottom

pub fn remove_go_string(&mut self, go_string_to_remove: ByAddress<Rc<GoString>>)[src]

Remove a string from the game, it add liberties to all adjacent string of not the same color.

pub fn remove_captured_stones_turn(
    &mut self,
    color: Color
) -> (u32, Option<Point>)
[src]

Removes the dead stones from the goban by specifying a color stone. If there is only one stone captured, then update self.ko_point. Returns the number of stones removed from the goban.

impl Goban[src]

pub fn get_strings_of_stones_without_liberties_by_color(
    &self,
    color: Color
) -> impl Iterator<Item = ByAddress<Rc<GoString>>> + '_
[src]

pub fn get_string_from_stone(&self, stone: Stone) -> HashSet<Stone>[src]

Get the chain of stones connected to a stone. with a Breadth First Search, works for Empty stones too.

Ex: Passing a stone 'a' it will return and HashSet [a,b,t,z] with the string where the stone is. It will return the stone alone if it's lonely

pub fn get_strings_from_stones(
    &self,
    stones: impl Iterator<Item = Stone>
) -> Vec<HashSet<Stone>>
[src]

Pass a iterator of stones [x,a] and It will compute the string of each stone stones. Use a breadth first search to deduce the groups of connected stones. Get stones connected. [[x,y,z],[a,e,r]] example of return.

pub fn calculate_territories(&self) -> (usize, usize)[src]

Calculates a score for the endgame. It's a naive implementation, it counts only territories with the same color surrounding them.

Returns (black territory, white territory)

pub fn get_territories(
    &self
) -> (impl Iterator<Item = Stone>, impl Iterator<Item = Stone>)
[src]

Get two iterators of empty stones.

Trait Implementations

impl Clone for Goban[src]

impl Debug for Goban[src]

impl Default for Goban[src]

impl Display for Goban[src]

impl Eq for Goban[src]

impl Hash for Goban[src]

impl PartialEq<Goban> for Goban[src]

Auto Trait Implementations

impl !RefUnwindSafe for Goban

impl !Send for Goban

impl !Sync for Goban

impl Unpin for Goban

impl UnwindSafe for Goban

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> CallHasher for T where
    T: Hash
[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> ToString for T where
    T: Display + ?Sized
[src]

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>,