Game Report
Game Report
Game Report
for
<Project>
Version 1.0
Prepared by <author>
<organization>
<date created>
Copyright 1994-1997 by Bradford D. Appleton. Permission is hereby granted to make and distribute verbatim
copies of this document provided the copyright notice and this permission notice are preserved on all copies.(SDS
sections)
Modified by Dr Renata Rand McFadden
SoftwareDesignSpecificationfor<Project>
Page2
TableofContents
TableofContents...........................................................................................................................ii
RevisionHistory.............................................................................................................................ii
1. Introduction..............................................................................................................................1
1.1
1.2
1.3
1.4
1.5
1.6
Purpose..........................................................................................................................................1
DocumentConventions.................................................................................................................1
IntendedAudienceandReadingSuggestions................................................................................1
ProductScope................................................................................................................................1
References.....................................................................................................................................1
SystemOverview...........................................................................................................................2
2.1
2.2
2.3
2.4
AssumptionsandDependencies....................................................................................................2
GeneralConstraints.......................................................................................................................2
GoalsandGuidelines.....................................................................................................................2
DevelopmentMethods...................................................................................................................3
3.1
3.2
ArchitecturalStrategies.................................................................................................................3
HighLevelOverviewofSystemArchitecture...............................................................................4
4.1
4.2
ScreenImages................................................................................................................................4
ScreenObjectsandActions...........................................................................................................4
5.1
5.2
5.3
5.4
DataStructures..............................................................................................................................5
Component/Module/Feature1Name.............................................................................................5
Component/Module/Feature2Name.............................................................................................6
Component/Module/Feature3Name.............................................................................................6
2. DesignConsiderations.............................................................................................................2
3. SystemArchitecture.................................................................................................................3
4. HumanInterfaceDesign..........................................................................................................4
5. DetailedSystemDesign............................................................................................................4
AppendixA:Glossary....................................................................................................................7
RevisionHistory
Name
Date
ReasonForChanges
Version
Initialdesign
1.0
SoftwareDesignSpecificationfor<Project>
Page1
1. Introduction
1.1Purpose
The design paradigm for the game Rock, Paper, Scissors and Saw is described in this document.
The game shall be designed and implemented in Python. The software design document aims to
demonstrate how the design will implement the procedural programming paradigms in the Software
Requirement specification (SRS).
1.2Document Conventions
The design has adopted the procedural approach. Times New Roman has been used as the standard
font for the document and boldface letters have been employed with proper indentation for topics of
interest.
1.4Product Scope
The product is a PC implementation of the game Rock, Paper, Scissors and Saw. It has been
written with the procedural programming approach with the programming language Python.
1.4.1
Purpose
The purpose of this document is to briefly design all the requirements for designing text based game
software named as Rock, Paper, Scissors and Saws. This will be implemented using Python. The
game will be designed for two human players and third player will be computer itself. The basic
SoftwareDesignSpecificationfor<Project>
Page2
feature of the game is when user starts the program, program will prompt for entering two name of
players and on successful entry of players, menu will be displayed with following menu items :
Play Game, Show game rules, Show Statistics, and Exit. Each menu will have different approach
and procedure. Users enter their selection using keyboard. Software will respond to user inputs and
performs the requested operation.
1.4.2
Player
StartProgram
PlayGame
Enternames
View
statistics
ListRules
Quit
1.5References
SoftwareDesignSpecificationfor<Project>
Page3
General information about Rock, Paper and Scissors can be found at:
http://en.wikipedia.org/wiki/Rock_paper_scissors
1.6System Overview
The program is written in Python. The user needs to install Python 2.7.11 to be able to run the
program. There are no other dependencies other than Python itself. The program has to be run from
the console.
2. Design Considerations
Main design considerations are:
2.2General Constraints
Following constraints have been identified while designing the system:
I.
II.
End user environment: Two players have to be named for the game to continue.
III.
IV.
SoftwareDesignSpecificationfor<Project>
V.
Page4
Memory and other capacity limitations: Statistics of the game will be stored as long as
user doesnt come out of the game after choosing to exit. At the start of the game
Statistics will be initialized to 0.
VI.
VII.
2.3
The main purpose of this system is to allow playing game called Rock, Paper, Scissors and Saw.
Game includes three players, of whom two are humans and the third is the computer. The goals of
the system are:
Displaying proper instructions so that players do not get stuck at any point of
playing.
Once the game has started, the player must play 3 rounds after which the game
returns to the menu. The player has a choice to terminate the game by selecting
exit.
2.4
Development Methods
To design the system, procedural approach has been chosen. The procedural approach derives from
structured programming and is based on the concept of procedure calls. It contains routines,
subroutines, or functions. These procedures can be called from any module or sub module.
SoftwareDesignSpecificationfor<Project>
Page5
3. System Architecture
3.1
Architectural Strategies
Thearchitectureanddesignhasbeeninfluencedbythefollowingdesigndecisionsandstrategies:
ThedesignshalluseProceduralApproach.Sinceproceduralprogrammingoftenemploysa
topdown design, the main program will delegate its tasks to different routines and
subroutines.
Executingtheprogramisonlyrequiresdoubleclickingonittostartit.
TheprogramcanbeeditedinanIDE.
Nodatabaseisusedbutanarrayisusedtostorethestatisticaldate.
SoftwareDesignSpecificationfor<Project>
3.2
Page6
FigureII:Highlevelarchitectureofgamesoftware
I.
When the program starts, the user will be prompted for two names. After the names are properly
taken, it displays a menu with the following options:
a. Play game: Three rounds or Rock Paper Scissors Saw will be played and after evaluation of the
winner or loser, we return to the menu.
b. Show game rules : Prints the rules of playing the game on the screen.
c. Show Statistics: This menu will show the statistics of game. Totally two rows will be appear. As
there are two human player for each round. total number of games won/lost/tied will be shown. At
initiation of the game, these statistics will be zero. After termination of the game, the saved
statistics will be lost.
d. Exit: This option closes the program.
Computer
SoftwareDesignSpecificationfor<Project>
Page7
Console
FigureIII:DeploymentDiagram
4.1Screen Images
Screen 1 : Initial Screen
FigureIV:InitialScreen
Description: After clicking on the file icon, the game will start and ask for the names of the
two players. If answer is accepted, games proceeds towards menu, otherwise it asks for input
again.
Screen 2 : Menu
FigureV:Menu
SoftwareDesignSpecificationfor<Project>
Page8
SoftwareDesignSpecificationfor<Project>
Page9
Description : When the players names are properly entered, a menu is displayed. The
options in the menu are:
1. Play game
2. Show game rules
3. Show statistics
4. Exit
After selecting one of the options by typing the option number, we are taken to the
respective screen.Screen 3: Play Game
FigureVI:PlayGame
Description : When option 1 is selected, the game starts and the first player is asked to
choose a weapon from the choices Rock, Paper, Scissors and Saw followed by the
SoftwareDesignSpecificationfor<Project>
Page10
second player. The computer randomly chooses a weapon the results of the round are
evaluated for the two players separately. This goes one for two more rounds after which the
winners or loses of the current game are announced and the user is taken to the menu.
SoftwareDesignSpecificationfor<Project>
Page11
Exit
Description: When user selects 4 from menu option program will be terminated or
closed.
4.2
A. Screen 1 : When the user starts the program, it will first ask for the name of first player. If
the name entered is shorter than 5 letters or greater than 20 letters it will display an error
message and ask the user to type the name again. If input is successful it will ask the second
player to enter his name and display similar error messages if the mistakes are repeated. The
name of second player also has to be different from first player, otherwise an error will be
shown and the player will be asked to type the name again. After successful input, it will go
to screen 2 and display menu.
SoftwareDesignSpecificationfor<Project>
Page12
B. Screen 2 : The menu has 4 options: 1. Play game, 2. Show game rules, 3. Show statistics, 4.
Exit. The computer will take input from keyboard and accordingly change screens for the
user.
C. Screen 3 : When option 1 is selected, the game starts and the first player is asked to choose
a weapon from the choices Rock, Paper, Scissors and Saw followed by the second
player. The computer randomly chooses a weapon the results of the round are evaluated for
the two players separately. This goes one for two more rounds after which the winners or
loses of the current game are announced and the user is taken to the menu.
D. Screen 4 : When option 2 is selected, rules of the game are displayed which have to be
followed to play the game.
E. Screen 5 : When option 3 is selected, the results of the preceding rounds are tallied and
displayed and the overall winner is announced.
F. Selecting option 4 will close the program.
Other than stats_list, various temporary lists are declared inside functions to validate user
input.
SoftwareDesignSpecificationfor<Project>
5.2
Page13
When the user starts the program, it will first ask for the name of first player. If the name
entered is shorter than 5 letters or greater than 20 letters it will display an error message and
ask the user to type the name again. If input is successful it will ask the second player to
enter his name and display similar error messages if the mistakes are repeated. The name of
second player also has to be different from first player, otherwise an error will be shown and
the player will be asked to type the name again. After successful input, it will go to screen 2
and display menu.
5.2.1
Responsibilities
Prompts name of the two players and checks if they are valid according to constraints
5.2.2
Uses/Interactions
When the names are properly entered, the program displays the menu and allows the user to
take further action.
5.2.3
Constraints
The names of either player can not be shorter than 5 letters or longer than 20 letters.
5.2.4
Composition
The functions prompt1 and prompt2 both take the input for player names and check them for
validity, and keep recursively calling themselves until proper input is received.
5.2.5
Resources
SoftwareDesignSpecificationfor<Project>
None
5.2.6
Processing
#Mainfunction
if__name__=='__main__':
person1=prompt1()
person2=prompt2(person1)
#printperson1;
#printperson2;
#printrandom.choice([1,3,4,5])
stat_list=[[[0,0,0],[0,0,0]],[[0,0,0],[0,0,0]]]
opt=0;
while(True):
opt=menu()
if(opt==1):
play(person1,person2,stat_list)
elif(opt==2):
rules()
elif(opt==3):
stats(person1,person2,stat_list)
elif(opt==4):
goodbye()
break
#Methodstoreadinputfromkeyboard
def prompt1():
a=raw_input("What is the name of the first player?")
if (len(a) <5 or len(a) > 20):
invalid_name_error()
return prompt1();
return a;
def prompt2(b):
a=raw_input("What is the name of the second player?")
if (len(a) <5 or len(a) > 20):
invalid_name_error()
Page14
SoftwareDesignSpecificationfor<Project>
Page15
return prompt2(b);
elif (a==b):
duplicate_name_error()
return prompt2(b);
return a;
# Methods to print error messages
def invalid_name_error():
print ('Error: The name of the player can not be shorter than 5 or greater than 20 letters. Please
retry.')
def duplicate_name_error():
print ('Error: The name of the second player can not be the same as the first player.')
def menu_selection_error():
print ('Error: Please choose a valid option.')
def move_selection_error():
print ('Error: Please select one of the options - "rock", "paper", "scissors" or "saw"')
5.3
5.3.1
Responsibilities
5.3.2
Uses/Interactions
SoftwareDesignSpecificationfor<Project>
Page16
Selecting Play game (pressing 1 from keyboard) will allow the user to play 3 rounds of a
game.
Show game rules (pressing 2 from keyboard) will display the rules that need to be
followed to play the game.
5.3.3
Constraints
User will have choice to select option from 1 to 4. An error message will be thrown if user
enters anything apart from these numbers.
5.3.4
Composition
User has to select from option 1 to 4. In case wrong selection is done, error message will be
displayed and menu will be redisplayed.
5.3.5
Resources
5.3.6
Processing
None
#listofmenuswillbedisplayed.
defshowMenu():
print'Menu:'
print'1.Playgame'
print'2.Showgamerules'
print'3.Showstatistics'
print'4.Exit'
#Menu()Function
defmenu():
showMenu()
while(True):
SoftwareDesignSpecificationfor<Project>
Page17
try:
opt=int(raw_input('Pleaseselectanoption:'))
if(opt>=1andopt<=4):
break
else:
menu_selection_error()
except:
pass
returnopt
5.4
G. When option 1 is selected, the game starts and the first player is asked to choose a weapon
from the choices Rock, Paper, Scissors and Saw followed by the second player. The
computer randomly chooses a weapon the results of the round are evaluated for the two
players separately. This goes one for two more rounds after which the winners or loses of the
current game are announced and the user is taken to the menu.
5.4.1
Responsibilities
This option will allow user to start playing the game. For each game, three rounds will be
played. On subsequent round winner or loser will be announced. Two human players and
computer will play as third player.
Each player will be prompted to choose a weapon from one of Rock, Paper, Scissors
or Saw. The computer will randomly choose one of the four and the results of each round
will be evaluated according the rules and finally the results of the game will be announced
after 3 rounds.
5.4.2
Uses/Interactions
SoftwareDesignSpecificationfor<Project>
Page18
Program will prompt the player to choose one of Rock, Paper, Scissors, or Saw. So that it will be
clear which player has selected what. The third player will be the computer. Result will also shown
along with name.
5.4.3
Constraints
Any choices besides Rock, Paper, Scissors or Saw this will result in an error message.
5.4.4
Composition
5.4.5
Resources
5.4.6
Processing
None
#Playingthegame
defplay(p1,p2,sl):
player1_wins=\
player1_losses=\
player2_winss=\
player2_losses=0
player_list=[]
player_list.append(p1)
player_list.append(p2)
selection=['','']
forroundinrange(1,4):
print'\nRound%d:\n'%(round)
player_serial=1
forpinplayer_list:
valid=False
choice=''
whilenot(valid):
SoftwareDesignSpecificationfor<Project>
Page19
choice=get_choice(p)
#dchoice=choice.tolower()
ifchoice.lower()notin{'rock','paper','scissors','saw'}:
move_selection_error()
continue
valid=True
selection[player_serial1]=choice
player_serial+=1
temp=['rock','paper','scissors','saw']
computer_idx=random.choice([0,1,2,3])
computer=temp[int(computer_idx)]
print('\n')
res_one=result(selection[0],computer)
ifres_one==1:
print'%schose%s.Thecomputerchose%s.%swinstheround'%(player_list[0],
selection[0],computer,player_list[0])
sl[0][0][0]+=1
player1_wins+=1
elifres_one==1:
print'%schose%s.Thecomputerchose%s.%shaslosttheround'%(player_list[0],
selection[0],computer,player_list[0])
sl[0][0][1]+=1
player1_losses+=1
else:
print'%schosewas%s.Thecomputerchose%s.%shastiedtheround'%(player_list[0],
selection[0],computer,player_list[0])
sl[0][0][2]+=1
res_two=result(selection[1],computer)
ifres_two==1:
print'%schose%s.Thecomputerchose%s.%swinstheround'%(player_list[1],
selection[1],computer,player_list[1])
sl[1][0][0]+=1
player2_winss+=1
elifres_two==1:
print'%schose%s.Thecomputerchose%s.%shaslosttheround'%(player_list[1],
selection[1],computer,player_list[1])
sl[1][0][1]+=1
player2_losses+=1
else:
print'%schose%s.Thecomputerchose%s.%shastiedtheround'%(player_list[1],
selection[1],computer,player_list[1])
sl[1][0][2]+=1
print'\nGameover:'
ifplayer1_wins>player1_losses:
print'%swinsthegame'%(player_list[0])
sl[0][1][0]+=1
elifplayer1_wins<player1_losses:
print'%shaslostthegame'%(player_list[0])
sl[0][1][1]+=1
else:
print'%shastiedthegame'%(player_list[0])
SoftwareDesignSpecificationfor<Project>
sl[0][1][2]+=1
ifplayer2_winss>player2_losses:
print'%swinsthegame'%(player_list[1])
sl[1][1][0]+=1
elifplayer2_winss<player2_losses:
print'%slostthegame'%(player_list[1])
sl[1][1][1]+=1
else:
print'%shastiedthegame'%(player_list[1])
sl[1][1][2]+=1
return
#Winnerofaroundisevaluatedwiththisfunction
defresult(c1,c2):
ifc1=='rock':
ifc2=='rock':
return0
elifc2=='paper':
return1
elifc2=='scissors':
return1
elifc2=='saw':
return1
elifc1=='paper':
ifc2=='rock':
return1
elifc2=='paper':
return0
elifc2=='scissors':
return1
elifc2=='saw':
return1
elifc1=='scissors':
ifc2=='rock':
return1
elifc2=='paper':
return1
elifc2=='scissors':
return0
elifc2=='saw':
return1
elifc1=='saw':
ifc2=='rock':
return1
elifc2=='paper':
return1
elifc2=='scissors':
return1
elifc2=='saw':
return0
#getweaponchoice
Page20
SoftwareDesignSpecificationfor<Project>
Page21
defget_choice(player):
choice=raw_input('%s,pleasechooseonefrom["Rock","Paper","Scissors","Saw"]:'%
(player))
returnchoice
5.5
Rules of the game will be shown on entering option 2 from menu selection.
5.5.1
Responsibilities
5.5.2
Uses/Interactions
Listofruleswillbedisplayed.
5.5.3
Constraints
Noconstraints.
5.5.4
Composition
Ruleswillbedisplayedusingfunctionrules().
5.5.5
Resources
5.5.6
Processing
None
#DisplayRules
defrules():
print'\n1.resultoftheroundwillbedeterminedasfollow:'
print'a.RockbreaksscissorsandSawthereforerockwinsoverscissorsandsaw.Rockloses
againstpaper.'
print'b.Scissorscutpaperthereforescissorswinoverpaper.ScissorsloseagainstrockandSaw.'
print'c.Papercoversrockthereforepaperwinsoverrock.Paperlosesagainstscissorsandsaw'
print'd.Sawcutsthroughscissorsandpaperthereforesawwinsoverscissorsandpaper.Saw
losesagainstrock.'
print'e.Ifplayerandcomputermakethesameselection,thereisatie'
print'2.resultofthegameagainstthecomputerisonewhowonmorerounds(mustaccountfor
ties)'
SoftwareDesignSpecificationfor<Project>
Page22
print'3.Overallhumanresultisbasedonthegreaternumberofwongamesagainstthecomputer
andleastgameslost(mustaccountfortiebetweenhumanplayer_list)\n'
return
5.6
On selecting option 3 from menu options, statistics related to the game will be flashed.
At the start of the game, these are initialized to zero.
5.6.1
Responsibilities
5.6.2
Uses/Interactions
Player name, won, rounds lost, tie, games won, lost or tie will be displayed in a tabular way
5.6.3
Constraints
Noconstraints
5.6.4
Composition
Statisticswillbedisplayedusingfunctionstats().
5.6.5
Resources
None
5.6.6
Processing
#statisticswillbeshownforeachgame.
SoftwareDesignSpecificationfor<Project>
Page23
defstats(p1,p2,sl):
player_list=[]
player_list.append(p1)
player_list.append(p2)
totalplayer_list=len(player_list)
print'\n'
print'%s%s%s'%(''.center(24),'Rounds'.center(24),'Games'.center(24))
print'%s%s%s%s%s%s%s'%
('Name'.center(24),'Wins'.center(8),'Losses'.center(8),'Ties'.center(8),'Wins'.center(8),'Losses'.center
(8),'Ties'.center(8))
print'%s'%(''.center(72))
forplayer_numberinrange(totalplayer_list):
print'%s%s%s%s%s%s%s'%(player_list[player_number].center(24),\
str(sl[player_number][0][0]).center(8),\
str(sl[player_number][0][1]).center(8),\
str(sl[player_number][0][2]).center(8),\
str(sl[player_number][1][0]).center(8),\
str(sl[player_number][1][1]).center(8),\
str(sl[player_number][1][2]).center(8))
print('\n')
ifsl[0][1][0]>sl[1][1][0]:
print'%sistheoverallwinner'%(player_list[0])
elifsl[0][1][0]<sl[1][1][0]:
print'%sistheoverallwinner'%(player_list[1])
else:
ifsl[0][1][1]<sl[1][1][1]:
print'%sistheoverallwinner'%(player_list[0])
elifsl[0][1][1]>sl[1][1][1]:
print'%sistheoverallwinner'%(player_list[1])
else:
print'Theplayersaretied.'
return
5.7
Component 6 : Exit
5.7.1
Responsibilities
Closingtheprogram
5.7.2
Uses/Interactions
Closestheprogram
5.7.3
Constraints
SoftwareDesignSpecificationfor<Project>
None
5.7.4
Composition
Programwillbeterminatedwithagoodbyemessageusingfunctiongoodbye().
5.7.5
Resources
5.7.6
Processing
None
#goodbyemessage
def goodbye():
print '\nGoodbye\n'
Appendix A: Glossary
SDS : Software Design Specification
Page24