CSC207 - Project 3
Peg Solitaire

Assigned Dec 1st 2 p.m.
Part 1 Due Dec 5th 4 p.m.

Part 2 Due Dec 15th 7 p.m.

Overview

For this project, we will explore more object-oriented and event-driven programming in the context of graphical applications. We will create a program for one person to solve the Peg Solitaire game.

In particular, this project will cover the following concepts we have discussed in class:

Description

Peg Solitaire is a puzzle found in gift shops across the country and especially Cracker Barrel.

A good description of the game is detailed by Chuong Do

Peg solitaire describes a general class of peg-jumping games in which a player is initially presented with a board containing holes and wooden pegs filling a subset of these holes. For any given move, a player must select one of the pegs on the board which has an adjacent peg and an empty hole following that adjacent peg. The original peg is moved to the empty hole and the adjacent "jumped" peg is removed from the board. The game ends when no more legal "jumps" may be made. The object of the game is to remove all pegs from the board except one.

A sample move is shown below, where the peg in the middle of the left side of the triangle is moved to the top hole, and the peg inbetween is removed.


		        O                       #         
		       / \                     / \        
		      # - O                   O - O          # = peg
		     / \ / \                 / \ / \         O = empty hole
		    # - # - #     ---->     O - # - #
		   / \ / \ / \             / \ / \ / \
		  O - # - # - O           O - # - # - O
		 / \ / \ / \ / \         / \ / \ / \ / \
		O - O - O - O - O       O - O - O - O - O

Part 1: Design - 6%

For this project, you will create a python program using Pygame to let the user try to solve the peg game and simulate the jumping of pegs.

There will be three portions to the display, the board, the buttons, and the peg cup.

When the game is launched, it will display the board, with all but the top hole filled with pegs. There will be two buttons on the left side of the screen, one for RESET, one for QUIT. On the bottom right-hand side of the screen, there will be a cup, represented by two concentric circles, where jumped pegs are placed.

The user should be able to click on the RESET button or the QUIT button at any time. The RESET button will return all pegs to their initial hole. The QUIT button will immediately quit the game.

The user is also allowed to click on pegs that have a possible place to jump. When selected, the pegs will change colors, and the avaialble holes to jump into will also change colors. Holes are only available when a peg is inbetween the selected peg and the empty hole. The user can now either deselect that peg, or select an available hole. If the peg is deselected, all items revert to their normal colors. If an available hole is selected, the peg will move to the hole, and the jumped peg will move to the peg cup in the lower right-hand side. All items will return to their normal colors.

When there are no more possible pegs to be jumped, the game will display the following messages underneath the board, depending on how many pegs remain.

The user can then select to RESET, or to QUIT.

For part 1 of the assignment, create a design document detailing all the objects you will need to represent the display and interactions necessary to carry out the game. Be as detailed as possible, discussing the components and functionality needed for each part of the game.

Part 2: Implementation - 12%

I will release my design document on Friday December 5th, when Part 1 is due. It will have a sample implementation scheme to help you complete the project.

Extensions

You must choose one of the following extensions to your implementation. You can choose to implement the other extensions for extra credit, each worth an additional 2% of your final grade.

Choose Startup

The board always starts with the empty peg in the same position. Add a START button which lets the user choose a hole to be the initial empty hole.

Undo

There is not a way for the user to undo a mistake made, they can only reset the puzzle and start over. Add an UNDO button to your interface which will take back the immediately previous move, and makes it possible to backtrack all the way to the beginning of the game.

Solver

Your current implementation for this assignment allows one player to complete the solitaire puzzle. Create a SOLVE button that will reset the puzzle, then step through the solution, waiting 1 second between each jump. Note, this is not a general solver, going from any possible configuration, but from the basic initial setup.

Other Boards

We currently have one configuration, the triangle, available for play with our implementation. Research other configurations at Wikipedia and add buttons to let the user choose a different board.

What to Hand In

Log in to cs.centenary.edu through either Secure FTP or WinSCP using your cs login and password. Create a subdirectory from csc207 called project3. Copy your solitaire.py and pieces.py project into this directory, along with any other files you need to run your code. Make sure you have followed the Python Style Guide, and have run your project through the Automated Style Checker.

You must hand in:

and any other files necessary to run your code.
© Mark Goadrich 2008, Centenary College of Louisiana