pub struct Board {
    cells: Vec<Square>,
    pub width: usize,
    pub height: usize,
    pub current_turn: Team,
}
Expand description

Single state of a checkers board

Fields

cells: Vec<Square>

1D backing array of board squares for the 2D game board

width: usizeheight: usizecurrent_turn: Team

Implementations

Get a mutable reference to a board square by 1D array index

Get the 1D array indices for the diagonally adjacent squares of a given board square

Returns

None: If the given square is unplayable

Some(Vec): A variable length vector of 1D indices for diagonally adjacent squares. Vector may be between 1 and 4 items long depending on the location of the given square

Get a Direction structure for the diagonally adjacent squares of a given board square

Similar to the Board::adjacent_indices function with differently formatted results

Returns

None: If the given square is unplayable

Some(Direction): A Direction structure for the diagonally adjacent squares.

Filter an array of diagonal indices (Like those from Board::adjacent_indices, Board::jumpable_indices) for those that are legal for a team’s man, i.e. solely up or down the board

Get the 1D array indices for the diagonally jumpable squares of a given board square

Returns

None: If the given square is unplayable

Some(Vec): A variable length vector of 1D indices for diagonally jumpable squares. Vector may be between 1 and 4 items long depending on the location of the given square

Get a Direction structure for the diagonally jumpable squares of a given board square

Similar to the Board::jumpable_indices function with differently formatted results

Returns

None: If the given square is unplayable

Some(Direction): A Direction structure for the diagonally jumpable squares.

Get the difference between two BrdIdx objects

Get a copy of a board square by 1D array index

Get a copy of a board square by 1D array index

Get a copy of a board square by 2D BrdIdx index

Transform a 2D row/column board index into a single 1D index for use with Board::cells

Similar to Board::cell_index but with a BrdIdx instead of separate indices. Transform a 2D row/column board index into a single 1D index for use with Board::cells

Transform a 1D array index (for Board::cells) into a 2D game board index (by row/col)

Check whether a move given by source and destination indices is legal

Check that given move trajectory is valid for a man piece

Check that given move trajectory is valid for a king piece

Get cell index of jumpee square given from and to locations

Get a pointer to the backing array of board squares, Board::cells

Get the number of board squares

Get the number of remaining pieces

Get the number of remaining pieces for a player

Get the score value, Black - White pieces

Get the state of a board square by 1D array index

Get new board derived from current with given move applied

Get new board derived from current with given jump applied

Get row index for current team, top row for black, bottom row for white

Unwrap the jumpee piece from the square and Board::check_jumpee_team with Moveable response

Check that the source piece and the jumpee are of opposing teams

Check and apply king strength

Initialise a game board without game pieces

Reset the given board to a starting layout with 3 rows of opposing pieces

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

The wasm ABI type that this converts from when coming back out from the ABI boundary. Read more

Recover a Self from Self::Abi. Read more

The wasm ABI type that this converts into when crossing the ABI boundary. Read more

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary. Read more

Tests whether the argument is a “none” instance. If so it will be deserialized as None, and otherwise it will be passed to FromWasmAbi. Read more

Returns an ABI instance indicating “none”, which JS will interpret as the None branch of this option. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

The wasm ABI type references to Self are recovered from.

The type that holds the reference to Self for the duration of the invocation of the function that has an &Self parameter. This is required to ensure that the lifetimes don’t persist beyond one function call, and so that they remain anonymous. Read more

Recover a Self::Anchor from Self::Abi. Read more

Same as RefFromWasmAbi::Abi

Same as RefFromWasmAbi::Anchor

Same as RefFromWasmAbi::ref_from_abi

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Same as IntoWasmAbi::Abi

Same as IntoWasmAbi::into_abi, except that it may throw and never return in the case of Err. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.