![]() ![]() ![]() Pseudo code alone is enough to put me on the right track. (if we get here step 4 produced a undesired board state) undo the move made in step 4 and recall step 4 with the next possible move that peg could make, if any. I'm coding in Java, but since this is a bit vague I'm only expecting pseudo code answers. Find the first possible peg that can move in 1 or more directions call solve () for that peg and it's direction. Changing my jump() function could potentially affect my heuristic. This is for a school project so I have to implement an uninformed search and a heuristic search algorithm. I would have to change it to take the start and end position desired for each jump, which is easy enough to change, but I don't know if its better or worse for the algorithm. 4) If there is no such cell, pick the one with least possible values and pick one of the numbers at random. 3) If there is a cell with only 1 possible value, fill it in. 2) Scan the entire grid and check for all possible values for each cell. Is recursion a good method to solve this puzzle? My jump function currently works by only asking for the position you would want to jump to. The Solution Logic is as follows: 1) Fill in Boxes 1,5,9 in with the digits 1-9 in any random order. Between backtracking and updating the current peg I'm lost.ĭoes all of this sound too complicated? Should I just remove the moves and sCpeg() options and have the search algorithm randomly jump until a solution is found? When I was writing this idea out it sounds like a perfect example to use recursion on except I don't know how to properly use recursion in this scenario. If a solution is not found backtrack, update the current peg and repeat the process. It's done as a very basic heuristic for what I hope to be a search algorithm: Explore all the possible jumps available with one peg. Every time you change the current peg and use it to jump that counts as a move. I connected this to a moves variable for the purpose of solving it. The English (left) and European (right) setups of peg solitaire. Thereare two classic setups, the English and European variants, as shown in Figure 1. In my code for the game board object I have a function sCpeg(int a, int b) which changes the peg you are currently using to jump. The puzzle of peg solitaireisone consisting of a number of holes in a grid, some of which are filled with pegs. You take one peg and jump it over another into an empty hole and the goal is to have only one peg left. We find that there are 1,045,173,439 reachable patterns from the initial state. Our algorithm running on a (super)computer generates all possible patterns reachable from the initial state. Everyone knows of the cracker barrel triangle peg solitaire game. We start with a peg solitaire puzzle on a board of size 5 × 7, which consists of 35 holes filled using 34 pegs placed in all holes except the central hole. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |