# Problem when tracking amount of draws in Rock, Paper, Scissors, Spock

Page 1 of 1

## 5 Replies - 1251 Views - Last Post: 01 January 2013 - 06:13 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=304852&amp;s=816c9b9869bc352c84f6674bb653ff2e&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 mmmmm

Reputation: 0
• Posts: 4
• Joined: 04-July 07

# Problem when tracking amount of draws in Rock, Paper, Scissors, Spock

Posted 25 December 2012 - 09:34 PM

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
Is This A Good Question/Topic? 0

## Replies To: Problem when tracking amount of draws in Rock, Paper, Scissors, Spock

### #2 modi123_1

• Suitor #2

Reputation: 13855
• Posts: 55,312
• Joined: 12-June 08

## Re: Problem when tracking amount of draws in Rock, Paper, Scissors, Spock

Posted 25 December 2012 - 09:41 PM

### #3 mmmmm

Reputation: 0
• Posts: 4
• Joined: 04-July 07

## 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 mmmmm

Reputation: 0
• Posts: 4
• Joined: 04-July 07

## Re: Problem when tracking amount of draws in Rock, Paper, Scissors, Spock

Posted 25 December 2012 - 10:34 PM

Figured out the problem.
```
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 alexr1090

Reputation: 44
• Posts: 126
• Joined: 08-May 11

## 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 atraub

• Pythoneer

Reputation: 828
• Posts: 2,235
• Joined: 23-December 08

## 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?