Coder Social home page Coder Social logo

2048-ai's Introduction

Playing 2048 game with an Automated Bot.

Bot uses Expectimax search with the depth of 4 to find the best possible move.

Project is still in progress. During testing 1024 tile was produced every time and 2048 tile in 60% of the games.

Prerequisites

Game theory, Machine Learning, Minmax, Expectimax

Files Info

direct.py --> Expectimax implementation (main algorithm)

puzzle.py ---> Implementation of game (main file, run this file for demo)

logic.py ----> Implementation of game (backend)

merge_game.py -----> Helper file for merging the matrix

Demo

$ git clone https://github.com/vpn1997/2048-Ai

$ cd 2048-Ai

$ pip install -r requirements.txt

$ python puzzle.py

webp net-resizeimage 2

Heuristics

(In file direct.py)

I have used a score and a penalty function.

A configuration gets a high score if it follows snake line pattern.

Weights are assigned to individual tiles. You can tweak them to get better results.

Penalty is given depending on how many filled tiles are present (more filled tiles => bigger penalty).

You can download the game interface from https://github.com/yangshun/2048-python.

Future work

  1. Getting 2048 or bigger tiles at higher frequency.

  2. Using Reinforcement learning didn't give any promising results.

The highest tile it used to get during the game was 128.

So still working on improving that model.

Reference

https://stackoverflow.com/questions/22342854/what-is-the-optimal-algorithm-for-the-game-2048

2048-ai's People

Contributors

amos1969 avatar emanon42 avatar eqlion avatar jomyemmanuel avatar vpn1997 avatar wert1996 avatar yangshun 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.