pub struct Game {
current: Board,
selected_piece: Option<BrdIdx>,
previous_boards: Vec<Board>,
painter: Option<Painter>,
search_depth: usize,
pub last_node_count: usize,
pub perfect_chance: f64,
}
Expand description
Root-level structure for managing the game as a collection of board states
Fields
current: Board
selected_piece: Option<BrdIdx>
previous_boards: Vec<Board>
painter: Option<Painter>
search_depth: usize
last_node_count: usize
perfect_chance: f64
Implementations
sourceimpl Game
impl Game
sourcepub fn previous_board(&self, turn: usize) -> &Board
pub fn previous_board(&self, turn: usize) -> &Board
Get a read-only copy of a previous turn’s board
sourcepub fn current_board(&self) -> &Board
pub fn current_board(&self) -> &Board
Set current board to given
sourceimpl Game
impl Game
sourcepub fn current_board_cells(&self) -> *const Square
pub fn current_board_cells(&self) -> *const Square
Get pointer to current board’s squares
sourcepub fn current_board_len(&self) -> usize
pub fn current_board_len(&self) -> usize
Get pointer to current board’s squares
sourcepub fn current_turn(&self) -> Team
pub fn current_turn(&self) -> Team
Current turn’s team
sourcepub fn current_cell_state(&self, idx: &BrdIdx) -> Square
pub fn current_cell_state(&self, idx: &BrdIdx) -> Square
Get square on current board for given index
sourcepub fn set_search_depth(&mut self, search_depth: usize)
pub fn set_search_depth(&mut self, search_depth: usize)
Set tree depth for AI to search to
sourcepub fn set_selected(&mut self, idx: &BrdIdx)
pub fn set_selected(&mut self, idx: &BrdIdx)
Set given index as selected piece TODO: Check whether valid square?
sourcepub fn set_perfect_chance(&mut self, new_chance: f64)
pub fn set_perfect_chance(&mut self, new_chance: f64)
Set proportion of perfect moves from AI
sourcepub fn clear_selected(&mut self)
pub fn clear_selected(&mut self)
Clear currently selected piece
sourcepub fn make_move(&mut self, from: BrdIdx, to: BrdIdx) -> Moveable
pub fn make_move(&mut self, from: BrdIdx, to: BrdIdx) -> Moveable
Attempt to make a move given a source and destination index
sourcepub fn execute_move(&mut self, from: BrdIdx, to: BrdIdx)
pub fn execute_move(&mut self, from: BrdIdx, to: BrdIdx)
Update board state with given move and push new board into current state
sourcepub fn execute_jump(&mut self, from: BrdIdx, to: BrdIdx)
pub fn execute_jump(&mut self, from: BrdIdx, to: BrdIdx)
Update board state with given jump move and push new board into current state
sourcepub fn push_new_board(&mut self, board: Board)
pub fn push_new_board(&mut self, board: Board)
Push current board into the previous turns and set given board to current
sourcepub fn set_current(&mut self, board: Board)
pub fn set_current(&mut self, board: Board)
Set current board to given
sourcepub fn new(
width: usize,
height: usize,
piece_rows: usize,
first_turn: Team,
search_depth: usize
) -> Game
pub fn new(
width: usize,
height: usize,
piece_rows: usize,
first_turn: Team,
search_depth: usize
) -> Game
Get new game without board renderer
sourcepub fn new_with_canvas(
width: usize,
height: usize,
piece_rows: usize,
first_turn: Team,
search_depth: usize,
canvas_id: &str,
canvas_width: u32,
canvas_height: u32
) -> Game
pub fn new_with_canvas(
width: usize,
height: usize,
piece_rows: usize,
first_turn: Team,
search_depth: usize,
canvas_id: &str,
canvas_width: u32,
canvas_height: u32
) -> Game
Get a new game with canvas ID and dimensions
sourcepub fn set_painter(&mut self, value: Painter)
pub fn set_painter(&mut self, value: Painter)
Set painter for rendering boards
Trait Implementations
sourceimpl FromWasmAbi for Game
impl FromWasmAbi for Game
sourceimpl IntoWasmAbi for Game
impl IntoWasmAbi for Game
sourceimpl OptionFromWasmAbi for Game
impl OptionFromWasmAbi for Game
sourceimpl OptionIntoWasmAbi for Game
impl OptionIntoWasmAbi for Game
sourceimpl RefFromWasmAbi for Game
impl RefFromWasmAbi for Game
type Anchor = Ref<'static, Game>
type Anchor = Ref<'static, Game>
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
sourceunsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor
Recover a Self::Anchor
from Self::Abi
. Read more
sourceimpl RefMutFromWasmAbi for Game
impl RefMutFromWasmAbi for Game
sourceimpl WasmDescribe for Game
impl WasmDescribe for Game
Auto Trait Implementations
impl RefUnwindSafe for Game
impl !Send for Game
impl !Sync for Game
impl Unpin for Game
impl UnwindSafe for Game
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ReturnWasmAbi for T where
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for T where
T: IntoWasmAbi,
type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
Same as IntoWasmAbi::Abi
sourcefn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
Same as IntoWasmAbi::into_abi
, except that it may throw and never
return in the case of Err
. Read more