### Peg Solitaire with Depth First Search

```Peg Solitaire
with Depth First Search
B Y: I R I S G A R C I A
Peg Solitaire
 Single-player board game with pegs that can come in
many different shapes such as:




Cross
Square
Pyramid
Triangle
 The purpose of the game is to eliminate all pegs by
jumping over them, similar to the game of Checkers.
Peg Board
 The simplest peg solitaire
design is the triangular peg
board, often referred to as
the “Cracker Barrel” design.
 This design is similar to an
equilateral triangle where
each edge has the same
number of pegs, and each
row has one more peg than
the row above it.
 The Board can be represented
as a tree in order to
implement how to traverse it.
Depth First Search Algorithm
DepthFirstSearch(Board b, Peg start)
{
If (Grandchild.isEmpty())
Jump();
updateBoard(); //updates empty peg, location, etc.
else
backtrack(); // backtrack to previous and/or try right child
}
Class Diagram
Sequence Diagram
Use Case Diagram
References

Darby, Gary. "Peg Solitaire Game." DelphiForFun Home. 31 Mar. 2009
<http://www.delphiforfun.org/Programs/PegSolitaire.htm>. This source offers background information on
several different techniques in solving Peg Solitaire. It also includes different representations of Peg Solitaire
other than the "Cracker Barrel" design. It also implies that the Depth First Search as one of the most effective
solutions.

Matos, Armando B. "Depth-first search solves Peg Solitaire." Computer and Information Science Papers
by Armando B. Matos goes into detail about using the Depth-First Search to solve the Peg Solitaire problem.
Matos uses a tree to represent the pegs instead of a graph and gives computation type for implementing this
algorithm with different representations of Peg Solitaire.

Muhammad, Rashid B. "Depth First Search (DFS)." Depth First Search (DFS). Kent State University. 31 Mar.
2009
<http://www.personal.kent.edu/~rmuhamma/Algorithms/MyAlgorithms/GraphAlgor/depthSearch.htm>.
This source explains the uses of depth-first search and details its algorithm.

Neller, Todd. "Uninformed Search." Gettysburg College Computer Science. Gettysburg College. 31 Mar. 2009
<http://cs.gettysburg.edu/~tneller/resources/ai-search/uninformed-java/index.html>. This source describes
Peg Solitaire in a triangular hex grid, and gives a documented example of the source code.

O'Brien, Daniel M. "Peg Board Puzzle Solution Page." Daniel M. O'Brien - bootstrap page. 31 Mar. 2009
<http://www.danobrien.ws/PegBoard.html>. This source gives a more detail analysis of solutions for the
"Cracker Barrel" or triangulated representation of Peg Solitaire.
```