#79 Twenty Forty-Eight
Gabriele Cirulli, a web developer, invented the game 2048 in one weekend. It was inspired by Veewo Studios’ 1024 game, which in turn was inspired by Threes!, a game by the development team Sirvo. In 2048, you must merge numbers on a 4 × 4 board to clear them from the screen. Two 2s merge into a 4, two 4s merge into an 8, and so on. The game adds a new 2 to the board on each merging. The objective is to reach 2048 before the entire board fills up.
The Program in Action
When you run twentyfortyeight.py, the output will look like this:
Twenty Forty-Eight, by Al Sweigart al@inventwithpython.com
--snip-- +-----+-----+-----+-----+ ...
Get The Big Book of Small Python Projects now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.