• Stars
    star
    1,069
  • Rank 43,234 (Top 0.9 %)
  • Language
    Python
  • License
    MIT License
  • Created over 10 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

AI for the 2048 game

AI for the 2048 game. This uses expectimax optimization, along with a highly-efficient bitboard representation to search upwards of 10 million moves per second on recent hardware. Heuristics used include bonuses for empty squares and bonuses for placing large values near edges and corners. Read more about the algorithm on the StackOverflow answer.

Building

Unix/Linux/OS X

Execute

./configure
make

in a terminal. Any relatively recent C++ compiler should be able to build the output.

Note that you don't do make install; this program is meant to be run from this directory.

Windows

You have a few options, depending on what you have installed.

  • Pure Cygwin: follow the Unix/Linux/OS X instructions above. The resulting DLL can only be used with Cygwin programs, so to run the browser control version, you must use the Cygwin Python (not the python.org Python). For step-by-step instructions, courtesy Tamas Szell (@matukaa), see this document.

  • Cygwin with MinGW: run

      CXX=x86_64-w64-mingw32-g++ CXXFLAGS='-static-libstdc++ -static-libgcc -D_WINDLL -D_GNU_SOURCE=1' ./configure ; make
    

    in a MinGW or Cygwin shell to build. The resultant DLL can be used with non-Cygwin programs.

  • Visual Studio: open a Visual Studio command prompt, cd to the 2048-ai directory, and run make-msvc.bat.

Running the command-line version

Run bin/2048 if you want to see the AI by itself in action.

Running the browser-control version

You can use this 2048 AI to control the 2048 browser game. The browser control capability is meant as a proof of concept to show the performance of the AI; it will only work on the original 2048 browser game or any compatible clone, not all 2048 games.

Firefox

Enable Firefox remote debugging by setting the about:config options "devtools.debugger.remote-enabled" and "devtools.chrome.enabled" to true, then quit Firefox and restart it with the --start-debugger-server 32000 command-line option.

Open the game in a new tab, then run 2048.py -b firefox and watch the game! The -p option can be used to set the port to connect to.

Chrome

Enable Chrome remote debugging by quitting it and then restarting it with the remote-debugging-port command-line switch (e.g. google-chrome --remote-debugging-port=9222).

Open the game in a new tab, then run 2048.py -b chrome and watch the game! The -p option can be used to set the port to connect to.

More Repositories

1

sha1collider

Build two PDFs that have different content but identical SHA1 sums.
Python
410
star
2

universal-doom

A single .exe binary which runs DOOM on DOS 6, Windows 95 and Windows 10 (and probably everything in between).
Python
277
star
3

iOS-SOCKS-Server

iOS HTTP/SOCKS proxy server for fake-tethering
Python
259
star
4

eqgrp-free-file

Free sampling of files from the purported Equation Group hack.
Python
177
star
5

pwn-stuff

Miscellaneous utilities and such that I use for pwning. Open sourced since people might find these useful. Be warned: nothing is stable.
Python
129
star
6

ffsend

Python client for Firefox Send
Python
120
star
7

ntfsrecover

NTFS data-recovery program written in Python
Python
116
star
8

Il2CppVersions

Build scripts & historical header files for every available minor version of Unity's Il2Cpp project
C
108
star
9

ghidra-rickroll

Get rickrolled, right in your favourite NSA reverse engineering tool
C
77
star
10

socks5-ios

SOCKS server for iOS. Handy for defeating tethering speed limits, among other uses.
Objective-C
75
star
11

threes-ai

AI for the game Threes!
Python
57
star
12

iOS-Torrent-Client

A torrent client for iOS which runs on play.js - without sideloading or jailbreaking!
JavaScript
32
star
13

direct-handtracking

DIRECT - Depth IR Enhanced Contact Tracking
C++
30
star
14

fixedint

Fixed-width integers for Python
Python
28
star
15

doublethink

Doublethink challenge from DEF CON 2018
Python
23
star
16

ofxWin8Touch

Windows 8 touch driver for OpenFrameworks using WM_POINTER events
C++
21
star
17

openFrameworks-AndroidStudio

OpenFrameworks modifications to work with Android Studio
19
star
18

sstic-2021

Files for my solution to the SSTIC 2021 challenge
C
15
star
19

firefox-charset-extension

Override Character Encoding extension for Firefox
JavaScript
12
star
20

sublime-replace-with-python

"Replace with Python" for Sublime Text 2
Python
9
star
21

Insta360-X3-Firmware-Tools

Tools for unpacking and repacking firmware images for the Insta360 X3
Python
6
star
22

bgrep

Binary grep with support for sophisticated regexes and grep(1)-like usage
Python
6
star
23

steam-phishing-analysis

Analysis and dissection of a Steam login phishing site.
HTML
6
star
24

sstv-encoder

SSTV encoder for Terebeep challenge at PlaidCTF 2017
Python
5
star
25

net-nrbf

Utilities to dump and process .NET binary-serialized data streams.
Python
4
star
26

pogo-iv-reader

Screenshot-reading IV calculator for Pokemon GO
Python
4
star
27

android_remote_control

Control an Android phone's touchscreen via ADB.
Python
3
star
28

hexacon-2022

Files for my solution to the Hexacon 2022 challenge
Python
3
star
29

pandt

HCI P&T projects
C
3
star
30

libm3

Library for reading and writing Blizzard .m3 model files.
C++
3
star
31

sstic-2023

My writeup for the SSTIC 2023 challenge (https://www.sstic.org/2023/challenge/)
Python
3
star
32

ghidra-skeleton-language

Skeleton language module for Ghidra
Java
2
star
33

sarah2-attack

Cryptanalysis of the Sarah2 pen-and-paper cipher
Python
2
star
34

weka-android

Weka for Android.
Java
1
star
35

ofxGestureCam

OpenFrameworks addon for the Creative Gesture Cam
C
1
star