5 Replies - 787 Views - Last Post: 01 January 2013 - 06:13 PM Rate Topic: -----

#1 mmmmm  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9277
  • View blog
  • Posts: 34,788
  • Joined: 12-June 08

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

Posted 25 December 2012 - 09:41 PM

how about posting it here?
Was This Post Helpful? 0
  • +
  • -

#3 mmmmm  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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()


Was This Post Helpful? 0
  • +
  • -

#4 mmmmm  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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.
Was This Post Helpful? 0
  • +
  • -

#5 alexr1090  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 44
  • View blog
  • Posts: 124
  • 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. :bananaman:
Was This Post Helpful? 0
  • +
  • -

#6 atraub  Icon User is offline

  • Pythoneer
  • member icon

Reputation: 759
  • View blog
  • Posts: 2,010
  • 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?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1