pub struct Game { /* private fields */ }
Expand description

Game holds the full state of a game of Hex and allows to manipulate this state by playing valid moves.

The game state consists of a board (get_board) and the current player (get_current_player).

Implementations

Create a new game with the given board size. Boards are always square.

Games always start with black.

This method will panic if the size is not bounded by MIN_BOARD_SIZE and MAX_BOARD_SIZE.

Return the game’s board.

Return the current player, or None if the game has ended.

Load a game from a StoneMatrix and a current player color.

This method returns an error if current_player is None, but the game has not yet finished. Conversely, if the game has finished, current_player will be ignored.

Please also have a look at the Serialization trait which allows to directly deserialize a game from JSON.

Let the current player place a stone at the given coordinates. If the move is invalid, this method returns an error. This method will automatically update the current player.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Save this game as a Serde JSON value

Load a game from a Serde JSON value.

Save this game to a JSON string.

Load a game from a JSON string.

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.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. 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.