pub struct Board { /* private fields */ }
Expand description
Game board representation
Implementations§
Source§impl Board
impl Board
Sourcepub fn new(size: usize) -> GameResult<Self>
pub fn new(size: usize) -> GameResult<Self>
Create a new empty board
Sourcepub fn set_tile(&mut self, row: usize, col: usize, tile: Tile) -> GameResult<()>
pub fn set_tile(&mut self, row: usize, col: usize, tile: Tile) -> GameResult<()>
Set tile at position
Sourcepub fn empty_positions(&self) -> Vec<(usize, usize)>
pub fn empty_positions(&self) -> Vec<(usize, usize)>
Get all empty positions
Sourcepub fn has_valid_moves(&self) -> bool
pub fn has_valid_moves(&self) -> bool
Check if any moves are possible
Sourcepub fn clone_board(&self) -> Self
pub fn clone_board(&self) -> Self
Get a copy of the current board state
Sourcepub fn from_tiles(tiles: Vec<Vec<Tile>>) -> GameResult<Self>
pub fn from_tiles(tiles: Vec<Vec<Tile>>) -> GameResult<Self>
Create board from tile data
Sourcepub fn count_tiles(&self, value: u32) -> usize
pub fn count_tiles(&self, value: u32) -> usize
Count tiles with a specific value
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Board
impl<'de> Deserialize<'de> for Board
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Board
impl RefUnwindSafe for Board
impl Send for Board
impl Sync for Board
impl Unpin for Board
impl UnwindSafe for Board
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more