Struct pack_2048::Game [−][src]
Fields
board: [[usize; 4]; 4]
score: usize
Methods
impl Game
[src]
impl Game
pub fn gen_tile(board: &mut [[usize; 4]; 4]) -> &mut [[usize; 4]; 4]
[src]
pub fn gen_tile(board: &mut [[usize; 4]; 4]) -> &mut [[usize; 4]; 4]
Generates a tile in a random empty cell of the provided board.
There is a 90% chance that a 2 tile is generated, and a 10% chance for a 4 tile.
pub fn get_text_board(board: &[[usize; 4]; 4]) -> String
[src]
pub fn get_text_board(board: &[[usize; 4]; 4]) -> String
Returns a text render of the board. Each column is dynamically sized to the number of digits in its largest member.
pub fn handle_move(board: &mut [[usize; 4]; 4], game_move: &Move)
[src]
pub fn handle_move(board: &mut [[usize; 4]; 4], game_move: &Move)
Handles a standard move and writes the result to the provided board.
pub fn is_gameover(board: &[[usize; 4]; 4]) -> bool
[src]
pub fn is_gameover(board: &[[usize; 4]; 4]) -> bool
Returns true if no valid moves are available.
pub fn move_east(board: &mut [[usize; 4]; 4])
[src]
pub fn move_east(board: &mut [[usize; 4]; 4])
pub fn move_north(board: &mut [[usize; 4]; 4])
[src]
pub fn move_north(board: &mut [[usize; 4]; 4])
pub fn move_south(board: &mut [[usize; 4]; 4])
[src]
pub fn move_south(board: &mut [[usize; 4]; 4])
pub fn move_west(board: &mut [[usize; 4]; 4])
[src]
pub fn move_west(board: &mut [[usize; 4]; 4])
pub fn new() -> Game
[src]
pub fn new() -> Game
Creates a new game state.