Code Monkey home page Code Monkey logo

solver2048's Introduction

highscore

Solver2048

Demo

You can view a live stream of the A.I. in action here: http://32768.eu.

Build

Main article: Building Solver2048

TL;DR: git clone https://github.com/mmiermans/solver2048.git && cd solver2048/Solver2048 && make && ./Debug/Solver2048

Performance

  • Max-tile histogram and score box-plot are included below the live stream.
  • Up to 17 million nodes/second.
  • Evaluates every possible position, up to 12 moves ahead.
  • Reaches the 16384 tile 55% of the time.
  • Reached the 32768 tile after 42 games in 48 hours.

Design

The solver has the following features:

  • The game state is stored compactly in a 64-bit integer bitboard.
  • A depth-first search is performed on an expectimax tree with alternating max and chance nodes.
  • Max and chance nodes are generated simultaneously to remove some duplicate nodes early on.
  • More duplicate nodes are prevented with a custom hashmap, which sacrifices theoretical correctness for raw performance and memory efficiency.
  • A simple and efficient cost function is used: sum all tiles, except those lying in a decreasing zig-zag pattern starting from the upper-left corner.
  • The solver cleverly determines the look-ahead (depth of the decision tree):
    • The look-ahead is based on the cost of the previous move, such that more computational time is spent on bad board positions.
    • The look-ahead is restricted to a range that depends on the sum of all tiles.
    • If there is a sharp increase in cost after the board is evaluated, then the evaluation is performed again with maximum look-ahead.

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.