Struct gomoku::board::go_board::GoBoard [] [src]

pub struct GoBoard {
    pub tiles: [[Tile; GO_WIDTH]; GO_WIDTH],
    size: usize,
}

Fields

tiles

The grid

First iterate over lines and then element by element.

size

Methods

impl GoBoard

fn get(&self, (x, y): (usize, usize)) -> Tile

The get function returns the tiles coordinates [x; y].

fn capture_dir(&mut self, x: usize, y: usize, rightdir: i32, downdir: i32, team: &mut Team)

fn capture(&mut self, x: usize, y: usize, team: &mut Team)

Test if playing this tile capture ennemy tiles and remove ennemy tiles and update number of captured tiles in the team if needed.

fn set_raw(&mut self, (x, y): (usize, usize), tile: Tile)

Assigns the value to tiles coordinates [x; y] without any check.

fn set(&mut self, (x, y): (usize, usize), team: &mut Team) -> bool

The set function assigns the value to tiles coordinates [x; y] if possible. Return false otherwise.

fn unset(&mut self, cell: (usize, usize))

The unset function assigns the FREE to tiles coordinates [x; y].

fn unset_gap(&mut self, coords: (usize, usize, i32, i32), gap: i32)

fn get_size(&self) -> usize

The get_size function returns the size of the grid side.

fn check_index(&self, (x, y): (usize, usize)) -> bool

The check_index function returns a boolean if the index is within the bounds of the board.

fn is_win_recursive(&self, x: i32, y: i32, downdir: i32, rightdir: i32, tile_type: Tile, ttl: usize) -> usize

fn is_win_direction(&self, x: usize, y: usize, downdir: i32, rightdir: i32) -> bool

Test if the tile at position [x, y] is winning on the direction [x - rightdir, y - downdir].

fn is_win(&self, x: usize, y: usize) -> Option<Tile>

Test if the tile at [x, y] is a winning one.

The type of the tile represent the winning team (if Tile::WHITE, the white team has won).

fn is_exp(&self, coords: (usize, usize, i32, i32), gap: i32, expected: Tile) -> bool

Return true if the tile which is positionned at gap tiles from the tested tile on the direction defined by coords is of the expected type.

fn free_threes_dir(&self, x: usize, y: usize, downdir: i32, rightdir: i32, team: &Team) -> u32

Return the number of free threes in this direction. Assume that tile[x, y] is free.

fn free_threes(&self, x: usize, y: usize, team: &Team) -> bool

Return true if the free threes rule allow this move.

A free-three is an alignement of three stones that, if not immediately blocked, allows for an indefendable alignment of four stones (that’s to say an alignment of four stones with two unobstructed extremities).

fn is_allow(&self, x: usize, y: usize, team: &Team) -> bool

Return true if it is allowed to add a tile on the position [x, y]. x and y are supposed to be valid index

fn is_empty(&self) -> bool

fn coord_out_of_index(index: usize) -> (usize, usize)

Return the (x, y) coordinates out of the index of the tile in the GoBoard::tiles array.

impl GoBoard

fn split_one_line(line: &str) -> Vec<Tile>

fn split_into_lines(to_parse: &String) -> Vec<&str>

fn execute_parse(size: usize, lines: &Vec<&str>) -> GoBoard

Parse a string which describe the inital state of the npuzzle board.

fn parse_with_size(to_parse: &String) -> GoBoard

This function also parse the size of the Board. This function should only be used in test because there is no test.

Trait Implementations

impl Display for GoBoard

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

impl Default for GoBoard

fn default() -> Self

Derived Implementations

impl Clone for GoBoard

fn clone(&self) -> GoBoard

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

impl PartialEq for GoBoard

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

fn ne(&self, __arg_0: &GoBoard) -> bool

impl Debug for GoBoard

fn fmt(&self, __arg_0: &mut Formatter) -> Result