How to optimally solve the flood fill puzzle?

后端 未结 10 1032
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

    Here's an idea for implementing the graph to support Smashery's heuristic.

    Represent each group of contiguous, same-colour squares in a disjoint set, and a list of adjacent groups of squares. A flood fill merges a set to all its adjacent sets, and merges the adjacency lists. This implicit graph structure will let you find the distance from the upper left corner to the farthest node.

提交回复
热议问题