0% found this document useful (0 votes)
6 views

Python Game Rspls

Uploaded by

better.you665
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Python Game Rspls

Uploaded by

better.you665
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

PYTHON RPSLS

DINODYA THILAKARATHNA
INTRODUCTION
What were we asked to do in this task?
Below are three examples of Python game:The class was asked to design a Python
game or an app using a code editor and
object-orientated programming language
Python.
Students had the option between
manipulating user inputs to create a
python game called a “mad libs
generator,” or even an option like a
“number guessing game.” However, I
chose the rock paper scissors game, or the
rock paper scissors lizard Spock game
which was extended for students aiming
for a higher grade (original game by Sam
Kass). Big Bang Theory mentions the game
for having a less chance at drawing due to
two more options being lizard and Spock.
Furthermore, this was not my original
learning curve for this assessment. Initially
I tried to setup a noughts and crosses
game using PyCharm for a graphics library
which initially did not work. As an
alternative I built the rock paper scissors
lizard Spock game.
BEGINNING SCREEN
An ideal beginning screen has all of the options available for the
player to select. This includes rock paper scissors lizard and Spock
laid out and aligned properly as such:

Why are good beginner screens needed?


This is because when a player wants to play a game such as one
built in Python, there can be a struggle to navigate around a text-
based system particularly if the instructions are going off the screen.
In which case, there would be issues with issues like this as some of
the rules\nwould have had to be spread onto new line with .
PROBLEMS AND SOLUTIONS
Problems:
1. Problem where random cannot directly draw a random integer out of a range,
you have to specify “randint” function first.
i
2. You would have had to add multiple statements of because of the ai being
f
able to pick one of the integers to specify a move as well. Due to this, there
might have been a situation where code was spread out along multiple lines.
To avoid this there were ifstatements
h == 1 andlike
b ==
this3used:
or (h == 3 and b == 1)
3. Originally, my plan was to use the
goto() function to travel between lines to create a
smooth flowing game where whatever you picked could to an option on the top or
bottom of the code.while True:
Alternatively, I used goto() because using would make
it difficult to allow for later editing of code.
4. Originally, most of the lines that needed to be displayed inside of the terminal where
not wrapping correctly for you to be able to see the whole sentence or line of text. To
\n
fix this issue I used print()marks of a
function inside of the quotation function.
POST MORTEM
During my time designing this game, I learnt many functions and uses that are tied with
Python. For my game however, it extensively used a module known as “random,” which
instructs python to pick an integer from a string, although not totally being random.
Originally, my plan was to make a naughts and crosses game to play against an
opponent and did not use an AI. However, I felt like this was out of my reach for the
time I had to complete this. So, as an alternative I settled with the Rock Paper Scissors
Lizard Spock game which uses the random module and an integer based win system
and AI.
Following my issue with the naughts and crosses idea not working, I planned ahead and
looked at alternative choices such as the rock paper scissors which was relatively
simple but still challenged my thinking.
What went wrong?
My original game, the naughts and crosses suffered from graphics glitches when the
size of the play board was expanded, resulting in a unavoidable glitch where nothing
would fit correctly.
Furthermore, a glitch was present where placing a marker on the board would cause the
whole Python terminal to crash and the game to stop running.
POST MORTEM CONTINUED
What went wrong?
Issues with time and limited knowledge on debugging and the Pygame module
became an issue with the naughts and crosses Python game.
Rock paper scissors lizard Spock:
An issue was that because both an player and a AI was present to play, a two
system had to be made using “or” statements and “and” statements.
Travelling between lines globally was not an option because of how the code had to
consistently edited. Instead, loops were used.
My rock paper scissors game originally would not work with a text-based system, so
I changed to an integer based system which simplified player interaction and inputs
with the code.
ORIGINAL CODE #4
if h == 4 and b == 5 or (h == 5 and b == 4):
print("Lizard poisoned spock!")
import random print("------------------------")

#5
var1 = input("Do you want to play, or find out why there are more options? (y/n/about): if h == 5 and b == 3 or (h == 3 and b == 5):
") .lower().strip() print("Spock smashed the scissors!")
if var1 == "y": print("------------------------------")
while True:
#6
print("What would you like to pick, type the appropriate integer?") if h == 3 and b == 4 or (h == 4 and b == 3):
h = int(input(" 1. Rock \n 2. Paper \n 3. Scissors \n 4. Lizard \n 5. Spock: ")) print("Scissors Decapitates lizard!")
# rps - ls print("---------------------------------------")
b = random. randint(1, 5)
#8
print("Your opponent has picked:", b) if h == 4 and b == 2 or (h == 2 and b == 4):
#1 print("Lizard eats Paper!")
if h == 3 and b == 2 or (h == 2 and b == 3): print("----------------------------")
print("Scissors cut paper!")
print("----------------------") #9
if h == 2 and b == 5 or (h == 5 and b == 2):
print("Paper disproves spock!")
#2 print("--------------------------")
if h == 2 and b == 1 or (h == 1 and b == 2):
print("Paper covers rock!") #10
if h == 5 and b == 1 or (h == 1 and b == 5):
print("--------------------") print("Spock vaporises rock!")
print("-------------------------")
#3
if h == 1 and b == 4 or (h == 4 and b == 1): #11
print("Rock covers lizard!") if h == 1 and b == 3 or (h == 3 and b == 1):
print("Rock crushes scissors!")
print("----------------------") print("-------------------------")

#12
if h == b:
print("It's a draw!")
print("---------------")

#13
if h > 5 or h < 1:
print("Answer is above or below number of options.")
print("---------------------------------------------")
ORIGINAL CODE CONTINUED
elif var1 == "about":
print("Rock Paper Scissors Lizard Spock (or RSPLS) is a modified game of the original "
"Rock Paper Scissors (or RPS).\nIt was modified to lower amount of draws by adding"
" more options.\n'Spock,' is a Star Trek reference and 'lizard,' was added by the original creator"
" Sam Kass. -Sheldon and Sam Kass.\n------------------------------------------------------------------"
"----------------------------------------------------")

elif var1 == "n":


print("Very well, the program will close now.")
exit()
else:
print("You have entered an invalid answer, closing the game.")

#1 ,2 ,3 ,4 ,5
#"Scissors cuts paper, paper covers rock, rock crushed lizard, lizard poisons Spock, Spock smashes scissors,

#6 ,7 ,8 ,9 , 10
# scissors decapitates lizard, lizard eats paper, paper disproves Spock, Spock vaporizes rock, and as it always has,

# 11.
# rock crushes scissors." -Sheldon and Sam Kass
PSEUDOCODE
#5
om module Pseudocode: if h is 5 and b is 3 or if condition on left are not met, try right (h is 3 and b
display("Spock smashed the scissors!")
display("------------------------------")
low is variable
splay question and then ask for input from user("Do you want to play, or find out why there are more options? (y/n/about): ") .decapitlalize().removespaces()
#6
e)1 is "y":
if h is 3 and b is 4 or if conditions on left are not met, try right (h is 4 and b
s True, or forever loop:
display("The scissors decapitated the lizard!")
lay("What would you like to pick, type the appropriate integer?")
display("---------------------------------------")
number user input only(take input from user(" 1. Rock \n 2. Paper \n 3. Scissors \n 4. Lizard \n 5. Spock: "))
s - ls
#7
random from set of options. random number between specified range on right(1, 5)
if h is 4 and b is 2 or if conditions on left are not met, try right (h is 2 and b
lay("Your opponent has picked:", variable b)
display("Scissors decapitates lizard!")
display("-----------------------------")
s 3 and b is 2 or if conditions on left are not met, try right (h is 2 and b is 3) if all conditions are met:
splay("Scissors cut paper!")
#8
splay("----------------------")
if h is 4 and b is 2 or if condition on left are not met, try right (h is 2 and b
display("Lizard eats Paper!")
display("----------------------------")
s 2 and b is 1 or if condition on left are not met, try right (h is 1 and b is 2):
splay("Paper covers rock!")
#9
splay("--------------------")
if h is 2 and b is 5 or if condition on left are not met, try right (h is 5 and b
display("Paper disproves spock!")
display("--------------------------")
s 1 and b is 4 or if conditions on left are not met, try right (h is 4 and b is 1):
splay("Rock covers lizard!")
#10
splay("----------------------")
if h is 5 and b is 1 or if condition on left are not met, try right (h is 1 and b
display("Spock vaporises rock!")
display("-------------------------")
s 4 and b is 5 or if condition on left are not met, try right (h is 5 and b is 4):
splay("Lizard poisoned spock!")
#11
splay("------------------------")
if h is 1 and b is 3 or if condition on left are not met, try right (h is 3 and b
display("Rock crushes scissors!")
display("-------------------------")
PSEUDOCODE CONTINUED
#12
if h is b and conditions are met:
display("It's a draw!")
display("---------------")

#13
if h is larger than 5 or h is smaller than 1:
display("Answer is above or below number of options.")
display("---------------------------------------------")
if the previous condition was not true then try this condition var1 == "about":
print("Rock Paper Scissors Lizard Spock (or RSPLS) is a modified game of the original "
"Rock Paper Scissors (or RPS).\newlineIt was modified to lower amount of draws by adding"
" more options.\newline'Spock,' is a Star Trek reference and 'lizard,' was added by the original creator"
" Sam Kass. -Sheldon and Sam Kass.\newline------------------------------------------------------------------"
"----------------------------------------------------")

if the previous condition was not true then try this one var1 == "n":
display("Very well, the program will close now.")
terminatepythonterminal()
if all other conditions are not met then do this anyways:
display("You have entered an invalid answer, closing the game.")

#1 ,2 ,3 ,4 ,5
#"Scissors cuts paper, paper covers rock, rock crushed lizard, lizard poisons Spock, Spock smashes scissors,

#6 ,7 ,8 ,9 , 10
# scissors decapitates lizard, lizard eats paper, paper disproves Spock, Spock vaporizes rock, and as it always has,

# 11.
# rock crushes scissors." -Sheldon and Sam Kass

You might also like