I need a matlab program to solve peg game, details are in the file attached

I need a matlab program to solve peg game, details are in the file attached

Document Preview:

Peg Game Final Project-FINAL MEC 102 – Jon Longtin, Spring 2014 http://shop.crackerbarrel.com/Peg-Game/dp/B0050PMMQA 15 positions, 14 filled at start Available Moves Peg Available Moves Peg Moves Peg Configurations 1 SW, SE 1-3, 1-10 1-2-3, 1-6-10 2 SW, SE 2-4, 2-11 2-3-4, 2-7-11 3 E, NE, SW, SE etc etc 4 E, NE 5 E, NE 6 SW, SE 7 SW, SE 8 E, NE 1 5 9 12 14 15 4 8 11 13 10 3 7 6 2 NE SE E SW W NW
9 E, NE 10 W, NW, SW, SE 11 W, NW 12 W, E, NW, NE 13 W, NW 14 W, NW 15 W, NW Algorithm (updated 4/24) 1) Prompt user for peg hole to remove 2) Populate 14 of 15 holes with pegs. Leave user-requested hole empth 3) Prompt user for number of solutions to find 4) Randomly pick hole a) Is peg in hole ? i) N0: break to next time through loop ii) YES: (1) Loop through available moves (pre-stored) (2) is current move being considered allowed? i.e., is there a peg present to jump, and is the hole two pegs away empty? (a) YES -> record as allowable move (b) NO -> break through next time through loop (3) IF no moves available, abort and start again from Step 4 ELSE IF only one move available, make it ELSE randomly chose one available move among several and make it (4) Store move [start hole, end hole] in solutions (5) Update status of pegs to reflect move (6) Set flag that move was made b) Was a move made? i) YES: (1) Is there only one peg left? (a) YES: Game over. You won! (b) No: Go to Step 2 for another round ii) NO: (1) Has the number of allowed moves been exceeded? (a) NO: Increment “no move made” counter, and got to Step 4 (b) YES: declare game over, no solution present c) Has the required number of solutions been found? i) YES: end program, ii) NO: got to Step 2 and repeat another try

Attachments:


You can leave a response, or trackback from your own site.
error: Content is protected !!