[−][src]Struct goban::pieces::goban::Goban
Represents a Goban. the stones are stored in ROW MAJOR (row, colum)
Implementations
impl Goban
[src]
impl Goban
[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]
&self,
coord: Point
) -> impl Iterator<Item = Stone> + '_
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]
&self,
coord: Point
) -> impl Iterator<Item = ByAddress<Rc<GoString>>> + '_
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]
&self,
index: usize
) -> impl Iterator<Item = ByAddress<Rc<GoString>>> + '_
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]
&self,
color: Color
) -> impl Iterator<Item = Stone> + '_
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]
&mut self,
color: Color
) -> (u32, Option<Point>)
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]
&self,
color: Color
) -> impl Iterator<Item = ByAddress<Rc<GoString>>> + '_
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]
&self,
stones: impl Iterator<Item = Stone>
) -> Vec<HashSet<Stone>>
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]
&self
) -> (impl Iterator<Item = Stone>, impl Iterator<Item = Stone>)
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]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> CallHasher for T where
T: Hash,
[src]
T: Hash,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,