Write 2048 games and game AI with cocos2d-x3.x and c++11

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.