Code Monkey home page Code Monkey logo

2048-rs's Introduction

2048-rs

Github tag Native Linux test status

This is a Rust implementation of the famous 2048 game which runs in the terminal.

In addition to the standard user inputs, an AI can be used to perform the moves. This AI leverages the expectiminimax algorithm to recommend the best next move at each step.

Game screenshot

Statistics

Here are the statistics of the AI with its default parameters:

max tile reached frequency average time to
reach max tile
2048 100 % 12s
4096 100 % 23s
8192 96 % 74s
16384 70 % 202s
32768 10 % 673s

Average times have been computed on a macbook pro 3,5 GHz Dual-Core Intel Core i7

In particular, these statistics correspond to a minimum branch probability of 0.001. Decreasing this value would lead to better performance, as more branches would be explored, but this would also take more time.

Some other hardcoded parameters can be tweaked in order to further improve the algorithm. I have not performed an exhaustive grid search, thus the parameter set is probably sub-optimal.

Installation

Rust and cargo must be installed to run this game:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

With Cargo

cargo install play-2048

Then, in order to play:

play-2048

From source

> git clone https://github.com/adrienball/2048-rs.git
> cd 2048-rs
> cargo run --release

Usage

You can change the probability of drawing a 4 tile:

> play-2048 --proba-4 0.5

Or adjust the minimum branch probability of the expectiminimax search:

> play-2048 --min-branch-proba 0.0001

To get the list of available options, simply run:

> play-2048 --help

License

Apache 2.0/MIT

All original work licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

2048-rs's People

Contributors

adrienball avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.