Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem Specification: The following game is actually a puzzle where the board has the form of a cross. It consists of 3 2 fields. 3

Problem Specification:
The following game is actually a puzzle where the board has the form of a cross. It consists of 32
fields. 31 of these fields contain a peg. The single field in the middle of the board is empty. We
mark a peg with X and an empty field with O in the following examples.
The rules of this game are simple:
you can take a peg and jump over another neighboring peg
the peg you jumped over is removed from the board
you solved the puzzle if at the end only on peg exists and is located in the middle of the board
At the start there are only a few possible moves, but the choices are increasing during the game.
Implement a recursive backtracking algorithm in Java, that finds a solution to this puzzle. Please
download the PegSolitaireSample before start. Your program must include a class called
PegSolitaireBoard which includes the following methods:
1. findSolution: Recursive and backtracking algorithm to compute all the possible moves move
current number of move, first move must be 1
2. moveForward: Moves the Xs and Os to the corresponding positions after the jump happens
3. moveBackward: moves the Xs and Os back to their initial position before the jump occurred
COSC2007: Assignment-1
4. checkMove: checks that the X performing the jump has one more X in between itself and
the O
5. print: print the current state of the board
Submission Instructions:
Please note that the submitted work will be considered as your own work and you
confirm that you have not received any unauthorized assistance in preparing for or
doing this lab/assignment/examination. You confirm knowing that a mark of 0 may
be assigned for entire work.
Submit your complete Java source files (.java). Comment your program carefully so that it can
be read and understood. If your program is not properly commented you may lose marks. See
marking scheme for details.
Marking Scheme:
You will receive full credits for the working code, otherwise zero. No partial credits!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Database Modeling With Neo4j

Authors: Ajit Singh

2nd Edition

B0BDWT2XLR, 979-8351798783

More Books

Students also viewed these Databases questions