mhw

Moore neighbourhood problem

May 20, 2010 18:27

If anyone doesn't know what the Moore neighbourhood is: it's the eight squares surrounding any square of a square grid.

I admit it, I'm feeling lazy. I could do it myself, with a bit of head-scratching, no doubt. But it's a nice little problem, particularly if you're au fait with a programming language that supports automatic backtracking, such as ( Read more... )

Leave a comment

Comments 15

atari_eric May 25 2010, 01:56:06 UTC
Okay, what we have here is essentially a 8-bit bitfield - A square can either be off or on. Therefore, it can have at most 256 combinations. But your restrictions reduce that number. Assuming we are numbering bits around the center square, a "rotation" as defined here is the equivalent of shifting the bits a multiple of 2 spaces in either direction. Reflections would involve changing the order of bits, anchoring a particular bit. For instance, the reflection of [0,1,2,3,4,5,6,7] at [2] would be [4,3,2,1,0,7,6,5]. Note that 6 stays in the same place, as the axis of rotation goes through bits x and x+4. One could go through all 256 possibilities (skipping marked off ones), rotate thrice and reflect four times, mark of the resulting bitmaps, and advance to the next untested map. Then count all the unmarked bitmaps when you're done testing.

Reply


Leave a comment

Up