Need some help with my code please.
Everything works fine except for when it keeps track of the draws
Written in Python Feel free to use it as you wish
http://pastebay.net/1167708
5 Replies - 411 Views - Last Post: 01 January 2013 - 06:13 PM
#1
Problem when tracking amount of draws in Rock, Paper, Scissors, Spock
Posted 25 December 2012 - 09:34 PM
Replies To: Problem when tracking amount of draws in Rock, Paper, Scissors, Spock
#2
Re: Problem when tracking amount of draws in Rock, Paper, Scissors, Spock
Posted 25 December 2012 - 09:41 PM
how about posting it here?
#3
Re: Problem when tracking amount of draws in Rock, Paper, Scissors, Spock
Posted 25 December 2012 - 09:49 PM
# Date: 12/25/12
# File: 503.py.py
from random import *
def DrawsNScore():
"""This Function makes the computer randomly score and compares that to the users input"""
NumWins = 0
NumLosses = 0
NumDraws = 0
for x in range(0,10,1):
RandomNumber = randint(1,5)
CompDraw = ""
Paper = "Paper"
Rock = "Rock"
Scissors = "Scissors"
Lizard = "Lizard"
Spock = "Spock"
if (RandomNumber == 1):
CompDraw = "Rock"
elif (RandomNumber == 2):
CompDraw = "Paper"
elif (RandomNumber == 3):
CompDraw = "Scissors"
elif (RandomNumber == 4):
CompDraw = "Lizard"
elif (RandomNumber == 5):
CompDraw = "Spock"
print CompDraw
R = "Rock"
r = "Rock"
P = "Paper"
p = "Paper"
X = "Scissors"
x = "Scissors"
l = "Lizard"
L = "Lizard"
S = "Spock"
s = "Spock"
UDraw = input("Please choose 'R', 'P','S', 'L', or 'S'\n")
if (CompDraw == UDraw):
print "You both drew " + str(UDraw)
print
elif (UDraw == R and CompDraw == Rock):
print "You both drew " + str(UDraw)
print
NumDraws = NumDraws + 1
elif (UDraw == P and CompDraw == Paper):
print "You both drew " + str(UDraw)
print
NumDraws = NumDraws + 1
elif (UDraw == X and CompDraw == Scissors):
print "You both drew " + str(UDraw)
print
NumDraws = NumDraws + 1
elif (UDraw == L and CompDraw == Lizard):
print "You both drew " + str(UDraw)
print
NumDraws = NumDraws + 1
elif (UDraw == S and CompDraw == Spock):
print "You both drew " + str(UDraw)
print
NumDraws = NumDraws + 1
elif (UDraw == R and CompDraw == Paper):
print
print "You Lost! Computer Drew " + str(CompDraw) + " and you drew " + str(UDraw)
print "Paper covers Rock"
print
NumLosses = NumLosses + 1
elif (UDraw == R and CompDraw == Lizard):
print
print "You Won! Computer Drew " + str(CompDraw) + " and you drew " + str(UDraw)
print "Rock crushes Lizard"
print
NumWins = NumWins + 1
elif (UDraw == R and CompDraw == Spock):
print
print "You Lost! Computer Drew " + str(CompDraw) + " and you drew " + str(UDraw)
print "Spock vaporizes Rock"
print
NumLosses = NumLosses + 1
elif (UDraw == R and CompDraw == Scissors):
print
print "You Won! Computer Drew " + str(CompDraw) + " and you drew " + str(UDraw)
print "Rock crushes Scissors"
print
NumWins = NumWins + 1
elif (UDraw == P and CompDraw == Rock):
print
print "You Won! Computer Drew " + str(CompDraw) + " and you drew " + str(UDraw)
print "Paper covers Rock"
print
NumWins = NumWins + 1
elif (UDraw == P and CompDraw == Lizard):
print
print "You Lost! Computer Drew " + str(CompDraw) + " and you drew " + str(UDraw)
print "Lizard eats Paper"
print
NumLosses = NumLosses + 1
elif (UDraw == P and CompDraw == Spock):
print
print "You Lost! Computer Drew " + str(CompDraw) + " and you drew " + str(UDraw)
print "Paper disproves Spock"
print
NumLosses = NumLosses + 1
elif (UDraw == P and CompDraw == Scissors):
print
print "You Lost! Computer Drew " + str(CompDraw) + " and you drew " + str(UDraw)
print "Scissors cuts Paper"
print
NumLosses = NumLosses + 1
elif (UDraw == X and CompDraw == Paper):
print
print "You Won! Computer Drew " + str(CompDraw) + " and you drew " + str(UDraw)
print "Scissor cuts Paper"
print
NumWins = NumWins + 1
elif (UDraw == X and CompDraw == Lizard):
print
print "You Won! Computer Drew " + str(CompDraw) + " and you drew " + str(UDraw)
print "Scissors decapitates Lizard"
print
NumWins = NumWins + 1
elif (UDraw == X and CompDraw == Rock):
print
print "You Lost! Computer Drew " + str(CompDraw) + " and you drew " + str(UDraw)
print "Rock crushes Scissors"
print
NumLosses = NumLosses + 1
elif (UDraw == X and CompDraw == Spock):
print
print "You Lost! Computer Drew " + str(CompDraw) + " and you drew " + str(UDraw)
print "Spock smashes Scissors"
print
NumLosses = NumLosses + 1
elif (UDraw == S and CompDraw == Lizard):
print
print "You Lost! Computer Drew " + str(CompDraw) + " and you drew " + str(UDraw)
print "Lizard poisons Spock"
print
NumLosses = NumLosses + 1
elif (UDraw == S and CompDraw == Rock):
print
print "You Won! Computer Drew " + str(CompDraw) + " and you drew " + str(UDraw)
print "Spock vaporizes Rock"
print
NumWins = NumWins + 1
elif (UDraw == S and CompDraw == Paper):
print
print "You Lost! Computer Drew " + str(CompDraw) + " and you drew " + str(UDraw)
print "Paper disproves Spock"
print
NumLosses = NumLosses + 1
elif (UDraw == S and CompDraw == Scissors):
print
print "You Won! Computer Drew " + str(CompDraw) + " and you drew " + str(UDraw)
print "Spock smashes Scissors"
print
NumWins = NumWins + 1
elif (UDraw == L and CompDraw == Rock):
print
print "You Lost! Computer Drew " + str(CompDraw) + " and you drew " + str(UDraw)
print "Rock crushes Lizard"
print
NumLosses = NumLosses + 1
elif (UDraw == L and CompDraw == Paper):
print
print "You Won! Computer Drew " + str(CompDraw) + " and you drew " + str(UDraw)
print "Lizard eats Paper"
print
NumWins = NumWins + 1
elif (UDraw == L and CompDraw == Scissors):
print
print "You Lost! Computer Drew " + str(CompDraw) + " and you drew " + str(UDraw)
print "Scissors decapitates Lizard"
print
NumLosses = NumLosses + 1
elif (UDraw == L and CompDraw == Spock):
print
print "You Won! Computer Drew " + str(CompDraw) + " and you drew " + str(UDraw)
print "Lizard poisons Spock"
print
NumWins = NumWins + 1
print
print
print " ####################"
print " ## SCOREBOARD ##"
print " ####################"
print " # Wins Losses Draws#"
print " # " + str(NumWins) + " # " + str(NumLosses) + " # " + str(NumDraws) + " #"
print " # #"
print " ####################"
def main():
print
print "Welcome to Rock, Paper, Scissors Spock!!"
print
print "You can choose either 'R' for Rock, 'P' for Paper,'X' for Scissors, 'L' for Lizard, or 'S' for Spock"
print
print "Remember Scissors cuts Paper, Paper cover Rock, Rock crushes Lizard, Lizard poisons Spock, Spock smashes Scissors, Scissors decapitates Lizard, Lizard eats Paper, Paper disproves Spock, Spock vaporizes Rock, and Rock crushes Scissors."
print "Good Luck!"
DrawsNScore()
main()
#4
Re: Problem when tracking amount of draws in Rock, Paper, Scissors, Spock
Posted 25 December 2012 - 10:34 PM
Figured out the problem.
Changed That ^
To This
Before, when I was writing the script for some reason the if statement wasn't working so I left it and added the elif's also for draws. I added more code and for some reason it started to work so I just added that one line and voila, it works.
UDraw = input("Please choose 'R', 'P','S', 'L', or 'S'\n")
if (CompDraw == UDraw):
print "You both drew " + str(UDraw)
print
elif (UDraw == R and CompDraw == Rock):
print "You both drew " + str(UDraw)
print
NumDraws = NumDraws + 1
Changed That ^
To This
UDraw = input("Please choose 'R', 'P','S', 'L', or 'S'\n")
if (CompDraw == UDraw):
print "You both drew " + str(UDraw)
NumDraws = NumDraws + 1
print
elif (UDraw == R and CompDraw == Rock):
print "You both drew " + str(UDraw)
print
NumDraws = NumDraws + 1
Before, when I was writing the script for some reason the if statement wasn't working so I left it and added the elif's also for draws. I added more code and for some reason it started to work so I just added that one line and voila, it works.
#5
Re: Problem when tracking amount of draws in Rock, Paper, Scissors, Spock
Posted 25 December 2012 - 11:52 PM
your prompt has two 'S' options in it.
#6
Re: Problem when tracking amount of draws in Rock, Paper, Scissors, Spock
Posted 01 January 2013 - 06:13 PM
Yeah, it stands for "Rock Paper Scissors Lizard Spock", he should probably come up with a better symbol for Scissors or spock... perhaps an "X" for scissors?
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote







|