2040AtePi

A 2048 port for Rapsberry Pi in ARM Assembly

Subscribe to updates I use 2040AtePi


Statistics on 2040AtePi

Number of watchers on Github 17
Number of open issues 0
Main language Assembly
Open pull requests 0+
Closed pull requests 0+
Last commit over 3 years ago
Repo Created over 3 years ago
Repo Last Updated 10 months ago
Size 533 KB
Organization / Author2040atepi
Contributors1
Page Updated
Do you use 2040AtePi? Leave a review!
View 2040AtePi activity
View on github
Latest Open Source Launches
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating 2040AtePi for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

2040 Ate Pi

2040 Ate Pi is a port of the game 2048 created by Gabrielle Cirulli, fully written in ARM11 Assembly for Raspberry Pi.

Introduction video: https://www.youtube.com/watch?v=QSlXWTzWZCY

It also includes a custom-built AI that can be improved. It is compatible with Revision B, and will be ported to version 2.

Feel free to contribute!

Gameplay

The main functionality of 2048 is implemented, with a graphical interface.

The recommended configuration is to use a joystick coupled with two buttons for Reset and AI mode. See below for GPIO pin details.

Installation

  • Install gcc-arm-none assembler
  • Navigate to src/
  • Add your gcc-arm-none assembler path in the Makefile
  • Run make in your Terminal
  • A kernel.img file will be generated. Replace the kernel.img file with it on the BOOT partition of the SD card of the Raspberry Pi (assuming Raspbian is installed). Make sure to backup your kernel.img file before.

Pins

Button Pin
18
22
23
17
Enable AI Mode 24
Reset Game 25

Artificial Intelligence

The game includes an Artificial Intelligence mode, which is toggle-able by one of the GPIO pins.

The AI used a randomized statistical approach to play the game. It calculates which way to move the board based on the following algorithm:

  1. Save the state of the current board
  2. Move up

a. Play random moves until the game ends

b. Calculate the score

c. Repeat steps 2.a. to 2.c 1000 times.

d. Calculate the average score obtained

  1. Do step 2. for Move left, Move down and Move right calculating the average score obtained for each direction.
  2. Move the original board in the direction with the highest average score. The score calculation mentioned in the algorithm is a slightly modified from the original game. In our version, when two tiles merge, we add the sum of their values to the score.

Hardware

Connect the Raspberry Pi to an HDMI display.

Our configuration uses a joystick and two buttons for Reset and AI mode (see below). The GPIO pins used can be changed easily in button.s.

Circuit

Improvement

There is always room for improvement. Here are some ideas:

  • Adding scoring
  • Improving animations and User Interface
  • Compatibility for other hardware

Generating Tiles from Images

To generate the assembly code for displaying the numbers, use our tile_generator.

All you need to do is put black and white png images in the images/ directory and run genscript.sh.

Note that the size of the images has to be 150x150 pixels and their names have to be of the form .png where number is a power of 2 between 2 and 131072.

Thanks to

Imperial College London and Raspberry Pi for Best ARM Final Year Project Prize (Year 1).

Cambridge University for providing a Raspberry Pi Graphics tutorial.

Uddhav Vaghela, Paul Balaji, Amin Karamlou.

Contributing

Franklin Schrans, Jacek Burys, Saurav Mitra, Srikrishna Subrahmanyam

Disclaimer

This project is protected under the MIT License.

2040AtePi list of languages used
Other projects in Assembly