Home > Back-end >  A solution to 2048 game program
A solution to 2048 game program

Time:09-28

Using the algorithm to solve 2048 game

On http://stackoverflow.com/questions/22342854/what-is-the-optimal-algorithm-for-the-game-2048/22389702#22389702 there are a lot of Daniel put forward its own solution,

Ovolve USES a - b pruning, which is typically used in game algorithm, such as: before in this way, Chinese chess,

Nicola Pezzotti features contributed a very easy the situation to the cleanliness of the algorithm to calculate...

Problem is that the above is js language, it is difficult to understand for me, and it is difficult to evaluate,

The individual feels algorithm itself is not difficult, difficult is how to understand their use of data structure, more specifically, the difficulty is how to assess the situation of algorithm (this problem, need to evaluate disk order degree and the overall score),

Finally, eyes rested on the algorithm of nneonneo, he used a bit - map technology, can make full use of space: from 0 to 15 each grid, corresponds to the 2 ^ 2 ^ 0 to 15, 64 can be used the whole situation said, do so much

Reduces the transmission parameters such as time-consuming, objectively saves time, in addition, also use an array to store the directly line score, evaluation category scores directly to the array values together, this is a very classic space in time,

His program can be downloaded on his git to https://github.com/nneonneo/2048-ai, here I also saved a under vs2008 can compile

Nneonneo

My program exactly like his, just didn't realize he used for pruning generic typedef STD: : map trans_table_t; Because I use Delphi 2010 without the corresponding function,

On my I5 2450, step needs about 2 s,

Uh, CSDN word count limitation...

The program can see in http://www.lab-z.com/2048ai/

Behind will improve:

1. Using the integer instead of single situation scores assessed in the program,

2. Implement nneonneo pruning algorithm, plans to use HouSisong Daniel DGL generic library at http://blog.csdn.net/housisong/article/category/152693

CodePudding user response:

Pick up points, don't mention it.

CodePudding user response:

In my i3 nneonneo code, Windows + cygwin, steps consume time ranged from 0.07 ~ 4.65 s,
I have been here:
1320
1232
Cb54
ed86

CodePudding user response:

I do not know what is the 2048 games,

CodePudding user response:

A good algorithm can improve bit performance,
To develop 2048 is challenging, I will only play, hey hey

CodePudding user response:

Why can't see you wrote it?

CodePudding user response:

2048 puzzle games, praise,
  • Related