Introduction This document describes the design of a single player interactive triangular peg board game with a variable number of pegs.

Slides:



Advertisements
Similar presentations
COSC2007 Data Structures II
Advertisements

Traveling Salesperson Problem
BackTracking Algorithms
CHAPTER 10 FUN AND GAMES Group 1: Xiangling Liu.
Graphs Graphs are the most general data structures we will study in this course. A graph is a more general version of connected nodes than the tree. Both.
 Chapter 7 introduces the stack data type.  Several example applications of stacks are given in that chapter.  This presentation shows another use called.
Stacks CS 3358 – Data Structures. What is a stack? It is an ordered group of homogeneous items of elements. Elements are added to and removed from the.
P Chapter 6 introduces the stack data type. p Several example applications of stacks are given in that chapter. p This presentation shows another use called.
1 CSE1301 Computer Programming: Lecture 23 Algorithm Design (Part 1)
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming The software development method algorithms.
November 10, 2009Introduction to Cognitive Science Lecture 17: Game-Playing Algorithms 1 Decision Trees Many classes of problems can be formalized as search.
Minesweeper is a game of logic. It originated from “Relentless Logic,” which was written by Conway, Hong, and Smith around In Relentless Logic, the.
Game Specific Options (Pre-Initialized) Board Size? Starting Position? Allow Diagonal moves or wins? Etc… Play Game (Initialized) Player is computer/human?
Lecture 4 1) RECURSION 2)BACKTRACKING 3)LOOK AHEAD.
Liang, Introduction to Programming with C++, Second Edition, (c) 2010 Pearson Education, Inc. All rights reserved Chapter 8 Multidimensional.
A game of logic where the player must assign the numbers 1..9 to cells on a 9x9 grid. The placement of the numbers must be such that every number must.
THE RENJU GAME BY ABHISHEK JAIN, PRANSHU GUPTA & RHYTHM DAS PCLUB SUMMER PROJECT PRESENTATION JUNE, L7 IIT KANPUR MENTOR – SANIL JAIN.
Chapter 3 Planning Your Solution
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
Peg Solitaire with Depth First Search
Data Structures Using C++ 2E Chapter 6 Recursion.
Recursion Chapter 7 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
Data Structures Using C++ 2E Chapter 6 Recursion.
Announcements.
OOD Case Study (For parallel treatment, see Chapter 2 of the text)
Boggle Game: Backtracking Algorithm Implementation
CSC-305 Design and Analysis of AlgorithmsBS(CS) -6 Fall-2014CSC-305 Design and Analysis of AlgorithmsBS(CS) -6 Fall-2014 Design and Analysis of Algorithms.
COSC2007 Data Structures II
Lecture 5: Backtracking Depth-First Search N-Queens Problem Hamiltonian Circuits.
Searching: Binary Trees and Hash Tables CHAPTER 12 6/4/15 Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education,
# 1# 1 VBA Recursion What is the “base case”? What is the programming stack? CS 105 Spring 2010.
Recursion: Backtracking
NxN Queens Problem Q- -- -Q Q- -- -Q Q- -- QQ -- Q- Q- Q- -Q QQ -- -Q -- -Q Q- -Q -Q Q- Q- -Q Q- -- Q- -- QQ Q- -Q -Q -Q -- QQ -- -Q START.
Two Dimensional Arrays
1 CS 410 Mastery in Programming Chapter 10 Hints for Simple Sudoku Herbert G. Mayer, PSU CS Status 7/29/2013.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
HPC Checkers By Andy Block Ryan Egan. Table of Contents Overview of Checkers ▫Overview of Checkers ▫Rules of the Game AI Theory The Program ▫Board ▫Sample.
Data Structures Using C++ 2E1 Recursion and Backtracking: DFS Depth first search (a way to traverse a tree or graph) Backtracking can be regarded as a.
Constraint Satisfaction CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
CSCI 5582 Fall 2006 CSCI 5582 Artificial Intelligence Fall 2006 Jim Martin.
Crystal Wettingfeld. Basic Board Design Board Design Showing Moves.
Chapter 5 Constraint Satisfaction Problems
The "8 Queens" problem Consider the problem of trying to place 8 queens on a chess board such that no queen can attack another queen. What are the "choices"?
COSC 2007 Data Structures II
CS 100Lecture 171 CS100A Lecture 17 n Previous Lecture –Programming concepts n Two-dimensional arrays –Java Constructs n Constructors for two-dimensional.
Backtracking & Brute Force Optimization Intro2CS – weeks
Introduction to State Space Search
Chomp. How is the game played Human player goes first choose a square, all to the right and down are “eaten” computer takes a turn whoever is forced to.
Checkers A Matlab Project by Spenser Davison, Edward Dyakiw, Justin Pezzi, and Scott Wu.
CompSci Problem Solving: Sudoku  Rules of the Game Sudoku is played with a 9 by 9 "board" consisting of nine 3 by 3 sub-boards. The symbols 1 -
1 Constraint Satisfaction Problems (CSP). Announcements Second Test Wednesday, April 27.
Recursion – some examples. Sum of Squares Write Vertical.
CSE 143 read: 12.5 Lecture 18: recursive backtracking.
Example Program Development
LINGO TUTORIAL.
CSG3F3/ Desain dan Analisis Algoritma
COMP 51 Week Fourteen Recursion.
Backtracking, Search, Heuristics
Intro to Computer Science II
A CIS 5603 Course Project By: Qizhong Mao, Baiyi Tao, Arif Aziz
1) RECURSION 2) BACKTRACKING 3) LOOK AHEAD
Using a Stack Chapter 6 introduces the stack data type.
Using a Stack Chapter 6 introduces the stack data type.
Kevin Mason Michael Suggs
Using a Stack Chapter 6 introduces the stack data type.
Stack Applications Lecture 29 Thu, Apr 5, /23/2019
Using a Stack Chapter 6 introduces the stack data type.
Sudoku.
Backtracking, Search, Heuristics
Data Structures & Programming
Presentation transcript:

Software Design Specification for a Triangular Peg Board Game By Leo Gonzalez

Introduction This document describes the design of a single player interactive triangular peg board game with a variable number of pegs.

Rules A legal move consists of a peg jumping horizontally or diagonally over an adjacent peg and into an empty hole. The peg that is jumped is removed from the board. A peg cannot jump over a hole. The player wins if there is only one peg remaining on the board. If no legal move is possible and there is more than one peg on the board, the player loses.

System Overview This program uses an object oriented design using C++.

General Constraints The program will be launched from the command line. The display will consist of text and the player will type commands to allow the software to run on a wide variety of hardware.

The Algorithm The algorithm of the main program can be summarized in the following pseudocode that is repeated until the user exits the program. Repeat : Prompt user for command If command is valid, execute Else Notify that command is not valid Until: Player quits

Use Cases MOVE UNDO SOLVE RESET BOARD PLAYER Figure 1 Peg Board DISPLAY MOVES PLAYER DISPLAY BOARD Figure 1

Goals and Guidelines This design tries to improve efficiency by minimizing the number of game states that are searched when the player directs the program to find a solution.

User Interface The display will use text to simulate a peg board. This is a 3 level board.   0,0:0 0,1:1 1,1:1 0,2:1 1,2:1 2,2:1 The coordinate system is based on George Bell’s Skew Cartesian coordinates system. The player will move by entering in the To and From coordinates. For example 2,2 0,0 would jump the peg located at 2,2, to 0,0 with the resulting board of …

0,0:1 0,1:1 1,1:0 0,2:1 1,2:1 2,2:0

Internal Representation The program defines a PegBoard Class and a MoveList Class. The PegBoard Class uses the MoveList class to represent both the moves made by the player. When the player commands the program to solve, the PegBoard creates lists of legal unique moves to be searched. These classes are shown in Figure 2. The interaction between the Player and the classes is shown in Figure 3. The PegBoard class uses a two dimensional array to represent the current board state. The MoveList class uses a pair of two dimensional arrays to represent the From and Two coordinates.

Class Diagram PegBoard Class Private: pegs integer[] [] numLevels integer movesMade MoveList possibleMoves MoveList[] solve() backtrack() checkSymmetry() Public: getNumLevels() getPeg(int row, int col) setPeg(int row, int col) setNumLevels(int n) move(int fromRow, int fromCol, int toRow, int toCol) displayBoard() displayMoves() newBoard(int lvlNum) MoveList Class Private: numMoves from int[][] to int[][] Public: getMoveFrom(int n,int result[]) getMoveTo(int n,int result[]) addMove(int from[], int to[]) removeMove(n) getNumMoves() Figure 2

Policies and Tactics The program will use a depth first search algorithm with backtracking to find a game state that is reachable from the current state in which there is only one peg left. If there is no such game state, the player will be notified that there is no possible solution from the current board configuration. The player will always have the option to undo moves and try to find a solution from a previous state.

Because every move removes exactly one peg from play, every possible solution will have exactly n-1 moves, where n is the number of pegs. Therefore, any solution found will have the minimum number of moves. When searching for a solution, the program will identify pegs that will lead to identical game states as other pegs, and removing them from consideration as possible moves. This solution is more efficient than a brute force approach. The recursive algorithm for finding a solution is as follows

Solve Algorithm Create a possibleMoves list Check current board for symmetry Add unique pegs to possibleMoves list For each possible move in the list execute move if one peg left, return solution. Else solve current board. Backtrack   If it backtracks to the top level, and there are no possible moves left, no solution was found.

Testing The program should be tested with different sequences of commands as the player has the option to enter any command at any time. Solutions that are found by the program should be tested by hand to confirm their accuracy. Multiple levels of board should also be tested.

Bibliography “Solitaire Puzzle with Backtracking”, by Paolo Martinoli http://www.codeproject.com/KB/cpp/SolitairePuzzle.aspx   “Triangular peg Solitaire”, by George Bell http://www.geocities.com/gibell.geo/pegsolitaire/tindex.html#gpjr “Solving Triangular Peg Solitaire” by George I. Bell. Journal of Integer Sequences, Vol. 11(2008), Article 08.4.8 http://arxiv.org/PS_cache/math/pdf/0703/0703865v6.pdf