

When a peg is jumped over, it disappears. You can only jump over one peg at a time. Then, pegs are made to jump over each other - you can only jump up and down, or left and right, not diagonally. At the start of a game of peg solitaire, a board is filled with pegs, except for one empty space. (After all, you can play the game in the opposite direction with a slightly different rule.Peg Solitaire (called Solitaire in the UK and Australia) is a really tough game of wits and logic. Should be solvable with roughly a 1GB memory pool and might be reasonably fast.Īnd you can improve it be cutting out a bit of redundancy (lots of rotational variants)Īnd maybe approaching it from both end could work. Then we proceed for every number with 2 up to 31 bits set, and check if any move leads to a marked solvable state.Īnd lastly you trace back from 2^33-2^16 through any solvable states to 2^16 to find a solution instance. So for 1 bit, index 2^16 gets marked as True, as it's the desired end state. My proposed solution is to work backwards with a bitarray of size 2^33, and for an increasing number of bits mark every index that leads to a solution.

Some people are average, some are just mean.

Qualification of 'a solution' can be reserved for later: a sequence's memorialization is 'easy' thanks to cells' numbering. 'A challenge' is to find 'a solution' - a sequence of jumps which, while clearing the board, terminate with a sole peg in cell 17. Or is it just to find a solution that is easy to repeat and remember?ĭespite the (thin) veneer of silliness, this puzzle has a fair amount of computer science heft to it - no nitpicking intended but what is 'the challenge' associated with this puzzle is debatable. Is the challenge to get the solution with the least number of moves? Surely all solutions will have the same number of moves, though. If Al Bundy had 33 Pegs he would probably lose his mind.
Peg solitaire java code#
If you wish - use it, with mouse-only, keyboard-only or a combination thereof, as is, no warranties, source code available upon request. (full disclosure: a C programmer, I have put together (and used) a Java program that does not search for a possible solution computationally but, rather, emulates a physical game and automatically records the moves made by a human: Ītomic jumps may be strung together into contiguous chains (which, imho, should not reduce the number of moves). Further, if a peg in cell 10 is chosen as a jumping peg then it must jump over a peg in cell 17 and it must land in cell 24 - it can not land in cell 29 despite the fact that that cell is empty. If '29 to 17' move was made then the peg in cell 24 is removed from the board and cells 29 and 24 become empty. Sample: initially, possible moves are: 5 to 17, 19 to 17, 29 to 17, 15 to 17. R4) a game terminates when no more legal moves are left - there does not exist a single triplet of cells with the properties described in r2 a peg that was jumped over, in cell B, is removed from the board be carried over a middle peg, in B, and in either case, only a peg in a peripheral cell, A or C, may jump and it must: R2) a jump is possible iff A, B and C are three adjacent cells in a column or row with either empty C and occupied A and B or empty A and occupied B and C (depicted): R1) one atomic move must be one legal jump The classical objective of this game is to leave exactly one peg on the board in dead center in the smallest number of moves each of which must follow these 'rectilinear checkers'-like rules: In a classical scenario, each cell but exactly one - in dead center - (cell 17), initially, has one peg (coin/marble/pebble/etc) in it: The board of this game, favored by Gottfried Leibniz (the co-inventor of D&I Calculus), consists of 33 cells. RIDDLES SITE WRITE MATH! Home Help Search Members Login RegisterĮasy (Moderators: Eigenray, Grimbal, towr, william wu, ThudnBlunder, Icarus, SMQ)
