![]() In other words, I think I need to remove this code: % Series of legal boards.Īnd change it so that it sets up a counter that stops at 22. Once we hit 22 moves (the max moves possible to clear the whole grid except for 1 peg), then the solution will be a success. Since it will always be this size, I figure the simplest way to find the end is to set up a counter that will count how many moves are taken place. For those of you unfamiliar, here is a video that illustrates. I figured I would have to do this because the grid isn't symmetrical. I've been reading research papers on how to solve a peg solitaire using graph search, but all the papers kind of assume you know how to do the reduction (polynomial time conversion) from the peg solitaire to the graph, which I do not, but this is how I assumed it was done. I liked the idea of rotating the grid to continue to simply figure out horizontal jumps, so I changed the rotate function to rotate it's side, and added a RotateBack function to put it back into place. I want this to show any possible solution. The triangular puzzle code required that the user input what the ending table would look like, but I didn't want that. %jump(B,A) :- rotate(BR,B), horizjmp(BR,BRJ), rotate(BRJ,A). Jump(B,A) :- rotate(B,BR), horizjmp(BR,BRJ), rotateBack(A,BRJ). ![]() Here's what I've got currently: % Legal jumps along a line. The problem I think I'm facing is trying to figure out how to let the program know it completed the puzzle. Description: A simple, easy-to-remember solution to the puzzle Peg Solitaire, also known as Solitaire, Solo Noble or Brainvita demonstrated by Crime Writer R. ![]() I'm trying to convert this code for solving a triangular peg solitaire puzzle into solving a rectangular peg solitaire puzzle. Possible quick question here since I'm new to Prolog. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |