Assignment-2 (1)
Assignment-2 (1)
Assignment-2
Due-date: Friday, February 14, 2025 @11:59pm
Cut-off date: Sunday, February 16, 2025 @11:59pm
Objective:
The objective of this assignment is to implement and solve peg solitaire by using recursion and
backtracking algorithms.
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
Table 1: Initial position of the pegs Table 2: Final position of the pegs
X X X O O O
X X X O O O
X X X X X X X O O O O O O O
X X X O X X X O O O X O O O
X X X X X X X O O O O O O O
X X X O O O
X X X O O O
are simple:
you can take a peg and jump over another neighboring peg
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. Your
program must display the board after the movement of every peg. Displaying only the
final board will not receive any credit. You may find it useful: How to Solve Peg Solitaire by
Robert Darke
Please download the PegSolitaireSample before start. You must use all the given
classes. You are not allowed to add/remove any classes. You are also not allowed to
COSC200700125W: Assignment-2
combine multiple class files into one file. You must use all the given methods without
changing their signatures. However, you may add new methods using the given ones
if necessary. Please note that you will not get any credit if your implementations do
not meet the criteria mentioned above.
Submission Instructions:
Please submit only your complete Java source files (.java). Do not submit compressed files,
entire projects, or any other types of files. 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.
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:
Please note that the submitted work will be considered as your own work and you con-
firm that you have not received any unauthorized assistance including Large Language
Models (LLMs) in preparing for or doing this lab/assignment/examination. You con-
firm knowing that a mark of 0 may be assigned for entire work.
Please download the PegSolitaireSample before start. You must use all the given
classes. You are not allowed to add/remove any classes. You are also not allowed to
combine multiple class files into one file. You must use all the given methods without
changing their signatures. However, you may add new methods using the given ones
if necessary. Please note that you will not get any credit if your implementations do
not meet the criteria mentioned above.