pub struct Game {
pub board_size: u8,
pub moves: Vec<Coord>,
// some fields omitted
}
A game of Hex, with move history. Metadata about the game (players, ratings, etc.) comes from a
GameMetadata
struct: this simply captures the actual moves and whether the players swapped.
Although colors differ between Hex implementations, this crate consistently has Black as the
player that moves first and who tries to connect the left and right sides, on a game board where
the top and bottom edges are flat and the top edge is to the left of the bottom edge.
The number of hexes on one edge of the board. This crate does not support hex games larger
than 26x26.
A list of moves, such that Black goes first and on every other odd-numbered move, and White
goes on every even-numbered moves. If the White player swaps on their first move, that should
be indicated by the game's metadata: in GameMetadata
, Black and White are the players as
they were at the end of the game, not as at the beginning.
If the list of moves is invalid for whatever reason (out-of-bounds coordinates, playing to the
same square twice, etc.), undefined behavior, including possible panics, can result.
Returns a new Game of the given size.
Returns the current game's status. As this is updated on each move and stored, this function
incurs almost no runtime cost.
Returns the color of the player next to move.
Makes the next move of the game, using whichever color is next to play. If the given
coordinate is invalid (it already has a piece or is out of bounds), returns false
and does
nothing. Otherwise, returns true
.
Returns the "default value" for a type. 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
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String
. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static