2048 Game On Python Project Synopsis
2048 Game On Python Project Synopsis
Submitted to:
Puneet Kaur
Submitted By:
Achintya Upadhyay
19BCS1714
2048 is a single-player sliding tile puzzle video game written by Italian web developer Gabriele Cirulli and
published on GitHub. The objective of the game is to slide numbered tiles on a grid to combine them to
create a tile with the number 2048; however, one can continue to play the game after reaching the goal,
creating tiles with larger numbers. It was originally written in JavaScript and CSS over a weekend, and
released on 9 March 2014 as free and open-source software subject to the MIT License. Versions
for iOS and Android followed in May 2014.
2048 is played on a plain 4×4 grid, with numbered tiles that slide when a player moves them using the
four arrow keys. Every turn, a new tile randomly appears in an empty spot on the board with a value of
either 2 or 4. Tiles slide as far as possible in the chosen direction until they are stopped by either another
tile or the edge of the grid. If two tiles of the same number collide while moving, they will merge into a tile
with the total value of the two tiles that collided. The resulting tile cannot merge with another tile again in
the same move. Higher-scoring tiles emit a soft glow; the highest possible tile is 131,072.[7]
If a move causes three consecutive tiles of the same value to slide together, only the two tiles farthest
along the direction of motion will combine. If all four spaces in a row or column are filled with tiles of the
same value, a move parallel to that row/column will combine the first two and last two. A scoreboard on
the upper-right keeps track of the user's score. The user's score starts at zero, and is increased whenever
two tiles combine, by the value of the new tile.
The game is won when a tile with a value of 2048 appears on the board. Players can continue beyond
that to reach higher scores. When the player has no legal moves (there are no empty spaces and no
adjacent tiles with the same value), the game ends.
The language being used to create this game is Python with the help of the software Tkinter.
Solving this game is an interesting problem because it has a random component. It’s impossible to
correctly predict not only where each new tile will be placed, but whether it will be a “2” or a “4”.
As such, it is impossible to have an algorithm that will correctly solve the puzzle every time. The best that
we can do is determine what is likely to be the best move at each stage and play the probability game.
At any point, there are only four possible moves that we can make. Sometimes, some of these moves
have no impact on the board and are thus not worth making – for example, in the above board a move of
“Down” will have no impact since all of the tiles are already on the bottom edge.
The challenge is then to determine which of these four moves is going to be the one that has the best
long-term outcome.
1. For left swipe, we will just compress and then merge the grid cell matrix and then if compress or
merge is true (indicating the values of the matrix is affected by previous two functions), then we need
to compress the grid again.
2. For moving up, we will take transpose then swipe left and again take transpose to return to the
original order.
3. Moving down is same as moving up but we need to reverse the matrix.
4. Similarly, right is same as moving left + reverse.
After every operation, we need to check the game status, if all cells are occupied and we cannot even
merge any two cells i.e. the state where no movement can change the matrix, then the game is over.
If any cell value has reached 2048, then the player is won and a message box is flashed on the screen
announcing the winner.
Everything from planning and coding to presentation and submission will be done by me
Achintya Upadhyay
19BCS1714
CSE5 (A)
A PC and Tkinter software for Python code also Pygame to incorporate images and sound to the game.
Bibliography
https://en.wikipedia.org/wiki/2048_(video_game)
https://en.wikipedia.org/wiki/Python_(programming_language)
https://en.wikipedia.org/wiki/Tkinter
https://www.baeldung.com/cs/2048-algorithm