Struct goban::pieces::goban::Goban [−][src]
pub struct Goban { /* fields omitted */ }
Expand description
Represents a Goban. the stones are stored in ROW MAJOR (row, column)
Implementations
Creates a Goban
Arguments
(height, width)
a tuple with the height and the width of the desired goban.
Creates a Goban from an array of stones.
Returns the underlying goban in a vector with a RowMajor Policy, calculated on the fly.
Get number of stones on the goban. (number of black stones, number of white stones)
Put a stones in the goban. default (line, column) the (0,0) point is in the top left.
Panics
if the point is out of bounds
Helper function to put a stone.
Get the chain from their id
Get all the neighbors to the coordinate including empty intersections.
Get all the stones that are neighbor to the coord except empty intersections.
pub fn get_neighbors_chain_indexes(
&self,
coord: Point
) -> impl Iterator<Item = ChainIdx> + '_
pub fn get_neighbors_chain_indexes(
&self,
coord: Point
) -> impl Iterator<Item = ChainIdx> + '_
Get all the neighbors indexes to the point. Only return point with a color.
Get all the chains adjacent to the point. The result iterator can contains duplicates.
pub fn get_neighbors_strings_indices_by_idx(
&self,
index: usize
) -> impl Iterator<Item = ChainIdx> + '_
Get all the stones except “Empty stones”
Get stones by their color.
Get points by their color.
Returns the empty stones connected to the stone
Returns true if the stone has liberties.
Get a string for printing the goban in normal shape (0,0) left bottom
Remove a string from the game, it add liberties to all adjacent chains that aren’t the same color.
pub fn get_chain_it_by_board_idx(
&self,
board_idx: BoardIdx
) -> impl Iterator<Item = usize> + '_
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
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.
Get two iterators of empty stones.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Goban
impl UnwindSafe for Goban
Blanket Implementations
Mutably borrows from an owned value. Read more