Algorithm and data structure for solving the game “Globs”/flood fill/“FloodIt”

后端 未结 7 2179
感情败类
感情败类 2021-01-31 19:35

Suggest an algorithm and data structure for solving the game Globs (http://www.deadwhale.com/play.php?game=131). It\'s pretty fun in a geeky kind of way.

State t

7条回答
  •  名媛妹妹
    2021-01-31 20:16

    A good heuristic is to generate the color-connected distance map. E.g. the current flood is at distance zero. A group of colors connected to a square at distance 'i' is at distance 'i+1'.

    Next, observe how many colors are at the maximum distance. We need maximum distance moves to eliminate one color at the maximum distance, and we need an additional move to eliminate each additional color at the maximum distance. If all colors are not at the maximum distance, consider the colors at the previous distance which have not yet been eliminated. We might eliminate one of these colors while making 'maximum distance' moves, but we will need a move to eliminate each additional color.

    This provides a fairly good estimate. On the initial 14x14 board position, I tend to get estimates of 17 to 18 while needing 20 to 22 moves for an optimal solution. A 14x14 board can typically be solved, with this lower bound, while looking at about 10,000 board positions. (Using the optimization of making a move that eliminates a color if such a move is available.)

提交回复
热议问题