GithubHelp home page GithubHelp logo

2048solver's Introduction

2048Solver

2048 webapp and AI solver in Python

Demo (not sped up)

2048-demo

Results

For 100 runs:

  • Achieves the 2048 tile 100% of the time
Result Score
Mean 105,369
Median 99,000
Max 289,920

Features

  • Expectimax, an adversarial search for non-deterministic games
  • Heuristics
    • Penalty for non-monotonic columns and rows
    • No. of empty spaces
    • No. of potential merges
    • Large values on the edge
  • Heuristic weights calculated with CMA-ES
  • Bitboard representation for grid
  • Transposition table to speed up search
  • Multithreading
  • Prune nodes below a dynamic probability threshold
  • Dynamic depth for search

Potential improvements

Dependencies

  • flask
  • cma
  • tqdm (for benchmarks)

How to use:

  • Run main.py to run flask webapp
  • Run calc_cma.py to calculate heuristic weights based on CMA-ES
  • Run benchmark.py for benchmarking

References

  • This StackOverflow answer for What is the optimal algorithm for the game 2048?
  • nneonneo/2048-ai
  • ziap/2048-tdl
  • W. Jaśkowski, "Mastering 2048 With Delayed Temporal Coherence Learning, Multistage Weight Promotion, Redundant Encoding, and Carousel Shaping," in IEEE Transactions on Games, vol. 10, no. 1, pp. 3-14, March 2018, doi: 10.1109/TCIAIG.2017.2651887.

2048solver's People

Contributors

zj-0 avatar

Watchers

 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.