How to optimally solve the flood fill puzzle?

后端 未结 10 1034
Happy的楠姐
Happy的楠姐 2020-12-12 15:35

I like playing the puzzle game Flood-It, which can be played online at:

https://www.lemoda.net/javascript/flood-it/game.html

It\'s also available as an iGoog

10条回答
  •  一个人的身影
    2020-12-12 16:35

    A* is just a prioritized graph search. Each node is a game state, you rank nodes based on some heuristic, and always expand the lowest-expected-final-cost node. As long as your heuristic doesn't underestimate costs, the first solution you find is guaranteed to be optimal.

    After playing the games a few times, I found that trying to drill to the opposite corner then all corners tended to result in a win. So a good starting cost estimate would be (cost so far) + a sufficient number of fills to reach the opposite corner [note: not minimum, just sufficient. Just greedily fill towards the corner to compute the heuristic].

提交回复
热议问题