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

前端 未结 6 615
心在旅途
心在旅途 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条回答
  •  爱一瞬间的悲伤
    2021-02-02 16:41

    A valid hash function, if you're really afraid of hash collisions, is to make a hash function x + order * y for coordinates and then loop trough all the coordinates of a piece, adding (order ^ i) * hash(coord[i]) to the piece hash. That way, you can guarantee you won't get any hash collisions.

提交回复
热议问题