In the words, the 19-year-old Italian Gabriele Cirulli was completed and released on GitHub in March 2014, and the game was designed from 1024, and 1024 was inspired by the mobile game of threes!. However, the popularity of the game soared beyond his imagination, people forget Flappy Bird, 2048 of the Internet "the most addictive things."
I am completely familiar with the cocos2d-x3.x version, only to write this game. This game is played as follows:
The game uses the arrow keys to move the block up or down. If two squares with the same number collide in the move, they are merged into a single block, and the number is changed to the sum of the two. Each time you move, a new block with a value of 2 or 4 appears. When a block with a value of 2048 appears, the game wins.
The difficulty of the game is to move and merge the operation, in fact, it is not difficult, but I think the writing is not elegant. It would be more ugly if you didn't use lambda. Other features don't come up with anything to say. Of course there are many places that can be perfected.
Finally, I also wrote an AI for this game, in theory can achieve a high success rate. But I measured the result is not very good, I think mainly because the efficiency is not high, the calculation is large, followed by the computer configuration has a relationship, after all, each step of the time interval can not be too long, this left a later improvement.
Finally, the attached piece and source code:
Source Address: https://github.com/booirror/game-2048
Finish
Write 2048 games and game AI with cocos2d-x3.x and c++11