Grid Similarity

One way to compare two grids is by the positions of the made moves. Essentially we want to create a hash value to identify grids that have the same moves but could have different lines.

To demonstrate this effect I have put together a demonstration.

Use the left and right arrow keys to cycle between configurations.
Grids sharing points with different lines

Hashing

To achieve this we iterate over the taken moves on the grid. We form a collection of strings with their x and y values. The list is then sorted and joined together by a token.

@taken_moves.collect{|move| "#{move.x},#{move.y}"}.sort.join('|')

NOTE: To keep the string shorter I SHA1 encode the string.

This provides a very quick way to tell if this configuration of points has been seen after a dna modification.

Advertisement
This entry was posted in Uncategorized. Bookmark the permalink.

1 Response to Grid Similarity

  1. Henryk says:

    Thanks for the very nice presentation of a grid!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s