2048 is a single-player sliding tile puzzle video game - en.wikipedia.org/wiki/2048_(video_game)
This project is a remake of a popular puzzle game 2048 with some small innovations. The game uses a 4x4 board and the player chooses the sliding direction each round. During each slide, two same neighbouring numbers in the direction will be summed up and all the other numbers will be compressed to the direction. The total score will be summed up by the sum of the two numbers that were combined. After each round, one of the numbers, 2 or 4, randomly appears in a random cell.
The purpose of the player is to combine numbers in one cell and create the number 2048 or to make the total score be larger than or equal to 25000. Once the player creates 2048 or reaches 25000 points, the player wins. If the player fails to create 2048 or 25000 points with all the cells already occupied (not equal to 0) and no chance of combining cells, the player will fail.
If the player successfully creates numbers greater than or equal to 512, but then fails, the "game-not-over condition" is met and a second chance will be given. Six random cells with numbers smaller than or equal to 128 will be cleared and the player can choose to continue playing with a punishment of subtracting 2048 from the total score.
To run code and play game, type "python3 New2048.py" into the terminal.
Sample gameplay:
2 0 4 0
0 0 0 0
0 0 0 0
2 0 0 0
Score: 0
Choose the direction to slide (a/w/s/d/e): w (Up)
4 0 4 0
0 0 0 0
0 0 0 2
0 0 0 0
Score: 4
The 2 in the third row and the fourth column is the randomly generated number after each slide.
The random number (2 or 4) can appear at any cell that is zero.
To choose in which direction numbers will slide, please use this key input element:
[w] - up [a] - left [s] - down [d] - left [e] - exit
Enjoy the game.