[][src]Struct hex_game::game::Game

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.

Fields

board_size: u8

The number of hexes on one edge of the board. This crate does not support hex games larger than 26x26.

moves: Vec<Coord>

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.

Methods

impl Game
[src]

pub fn new(size: u8) -> Game
[src]

Returns a new Game of the given size.

pub fn status(&self) -> GameStatus
[src]

Returns the current game's status. As this is updated on each move and stored, this function incurs almost no runtime cost.

pub fn next_move_color(&self) -> Color
[src]

Returns the color of the player next to move.

pub fn make_move(&mut self, coord: Coord) -> bool
[src]

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.

Trait Implementations

impl Default for Game
[src]

impl Clone for Game
[src]

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

Performs copy-assignment from source. Read more

impl Debug for Game
[src]

impl Display for Game
[src]

Auto Trait Implementations

impl Send for Game

impl Sync for Game

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

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

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

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

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]