Pebble

I watched this interesting¬†numberphile video¬†about ‘Pebbling a Chessboard’ or ‘Freeing the Clones’ and had to program it. Pebbling is an interesting game / problem / experiment which works like this:

There are three pebbles or clones in the corner of a chessboard and your task is to move all pebbles away from these three starting spaces (which are called the prison and you want to set the pebbles ‘free’). To move a pebble you place a new one below and another one to the right of the current one and then you remove the first pebble. Or in other words, you move the pebble one square down and place another one to the right of the original position. This way the pebble is duplicated, which is why it also can be called a clone. The only limitation on moving pebbles is that the two spaces where the new pebbles will be placed have to be empty, i. e. you are not allowed to stack pebbles on top of each other.

I played around with my own chessboard, but quickly ran out of figures, which I used as pebbles so I had to use other things as well. Also moving the pebbles took a little time and the space on the chessboard is limited.

That’s why I programmed Pebble using Haxe and OpenFL. You can try it in your browser and play around with the digital pebbles.

The blue-ish area is the prison. Click on a pebble to move it. If you move your mouse over a pebble it will change it’s color depending on whether it can move or not. Green means it can move and a darker red means it can’t.

Press R to reset.

Please note that in the video the moving direction is to the top right, while in my program it is to the bottom right.

Have fun!

If the flash version doesn’t work (like on iOS), try the HTML5 version.

Posted in Programming