tools-2048 0.1.0

A Rust crate that provides the core logic of the popular game 2048, along with a basic AI to play the game.
Documentation

tools-2048-rs

A Rust crate that provides the core logic of the popular game 2048, along with a basic AI to play the game.


Documentation

Crate

Example

use tools_2048::Game2048;

let mut game: Game2048 = Game2048::new();  // create a new game

// make 10 moves
for _ in 0..10 {
    game.make_move(game.moves[0]);
}

// make a move based on the AI's best move
game.make_move(game.find_best_move(10_000));

assert!(game.score > 0);  // the score should be greater than 0
assert!(!game.is_game_over());  // the game should not be over yet

The AI is based on the Monte Carlo algorithm, and uses parallelism to speed up the process.