Algorithm to identify a unique free polyomino (or polyomino hash)

前端 未结 6 609
心在旅途
心在旅途 2021-02-02 16:13

In short: How to hash a free polyomino?

This could be generalized into: How to efficiently hash an arbitrary collection of 2D integer coordinate

6条回答
  •  萌比男神i
    2021-02-02 16:50

    I worked on the same problem recently. I solved the problem fairly simply by (1) generate a unique ID for a polyomino, such that each identical poly would have the same UID. For example, find the bounding box, normalize the corner of the bounding box, and collect the set of non-empty cells. (2) generate all possible permutations by rotating (and flipping, if appropriate) a polyomino, and look for duplicates.

    The advantage of this brute approach, other than it's simplicity, is that it still works if the polys are distinguishable in some other way, for example if some of them are colored or numbered.

提交回复
热议问题