OU blog

Personal Blogs

neil

more groups and solitaire

Visible to anyone in the world
Edited by Neil Anderson, Friday, 20 Jan 2012, 18:39

Since my last post I've been thinking. Some messing around found me a pattern, a rather nice one for my purposes. Some background. 

I represent, even triangular Boards, as a HashMap of Pegs, some of these Pegs aren't valid. The hashCode() is just...

return (row * 10) + col;

Boards have rows and cols int properties, it doesn't make sense to rotate a Board if these are different. [Reflexion is another matter which I'll tackle later.]

When I started to think about rotation of a Board things got a little complicated. Take a ∏/2 anti-clockwise rotation. The Peg at 02 goes to 40, 05 goes to 10 etc.. Suddenly it hit me!

Take any row

10 11 12 13 14 15 16

Reverse it

16 15 14 13 12 11 10

Transpose the digits of the reversal

61 51 41 31 21 11 1

And map...

10 11 12 13 14 15 16

61 51 41 31 21 11 01

Which is the right answer and is pretty easy to programme. [Pseudo-code, I need to prove this one, I can't see any boundaries to test against.]

((Board.getRows() - Peg.getCol()) * (Peg.getRow() * 10)) + Peg.getRow();

So now I can programme a ∏/2 anti-clockwise rotation, which means I can compose to get the other rotations. Then I can loop through the pegMaps to see if they are equal (in the sense that they can be rotated onto one-another) and I can compare Boards up-to rotation.

I've come across something like this before; with Groups, conjugate cosets, permutations and equivelence. [I really do need to do some work on my Group Theory, because I know that I'm not describing this properly. I see the pattern, but I've forgotten what it's called, and means.]

Still I was right, there's more Groups to Solitaire than we thought.

 

Permalink Add your comment
Share post