pub struct GameState {
pub width: usize,
pub height: usize,
pub bombs: usize,
pub board: Vec<Vec<Cell>>,
pub game_over: bool,
pub won: bool,
}Expand description
Represents the current state of a minesweeper game
Fields§
§width: usize§height: usize§bombs: usize§board: Vec<Vec<Cell>>§game_over: bool§won: boolImplementations§
Source§impl GameState
impl GameState
Sourcepub fn new(
width: usize,
height: usize,
bombs: usize,
board: Vec<Vec<Cell>>,
) -> Self
pub fn new( width: usize, height: usize, bombs: usize, board: Vec<Vec<Cell>>, ) -> Self
Create a new game state
Sourcepub fn count_cells(&self) -> HashMap<String, usize>
pub fn count_cells(&self) -> HashMap<String, usize>
Count the number of cells in each state
Sourcepub fn is_game_over(&self) -> bool
pub fn is_game_over(&self) -> bool
Check if the game is in a completed state (won or lost)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GameState
impl RefUnwindSafe for GameState
impl Send for GameState
impl Sync for GameState
impl Unpin for GameState
impl UnsafeUnpin for GameState
impl UnwindSafe for GameState
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