1. Play on the ImDeity Minecraft Multiplayer server -- Goto the "Multiplayer" section of Minecraft and type "mc.imdeity.com" to join!
    Dismiss Notice

Anybody want to play rock paper scissors? :P

Discussion in 'General Discussions' started by jdonovin, August 21, 2015.

  1. jdonovin

    jdonovin

    • Gold
    Joined:
    February 8, 2013
    Messages:
    40
    Likes Received:
    43
    Trophy Points:
    163
    In-Game Name:
    jdonovin
    This post is a bit random but i think it would be interesting! Please post a code to play rock paper scissors on and don't forget to tell what code you used and just keep on posting and if you want post a link where you can test it!




    import random

    wins=0
    losses=0
    ties=0
    rounds=0

    r=1#rock
    p=2#paper
    s=3#scissors

    y ="The computer has made its choice, how about you?"

    while rounds <=10:print y
    x = input('(1)rock, (2)paper, or (3)scissors? :')
    choice = x
    cpu_choice= random.randint(1,3)

    if(choice, cpu_choice)==(1,2):
    rounds +=1
    losses +=1print'computer chose paper, you lose'elif(choice, cpu_choice)==(3,2):print'you win'
    rounds +=1
    wins +=1elif(choice, cpu_choice)==(2,2):print'TIE!'
    rounds +=1
    ties +=1elif(choice, cpu_choice)==(1,3):print'you win'
    rounds +=1
    wins +=1elif(choice, cpu_choice)==(3,3):print'TIE!'
    rounds +=1
    ties +=1elif(choice, cpu_choice)==(2,3):print'computer chose scissors, you lose'
    rounds +=1
    losses +=1elif(choice, cpu_choice)==(1,1):print'TIE'
    rounds +=1
    ties +=1elif(choice, cpu_choice)==(3,1):print'computer chose rock, you lose'
    rounds +=1
    losses +=1elif(choice, cpu_choice)==(2,1):print'you win'
    rounds +=1
    wins +=1else:print'Please choose 1, 2, or 3'

    print'Game Over'

    if wins>losses:print'YOU WON'print'wins:', wins print'losses', losses print'ties', ties else:print'you lose'print'wins:', wins print'losses:', losses print'ties:', ties

    I used Python, and I do not have a link to play it but if you find one please tell me :D
     
  2. heinz_gruber

    heinz_gruber

    • Sponsor
    Joined:
    October 2, 2011
    Messages:
    873
    Likes Received:
    1,607
    Trophy Points:
    628
    In-Game Name:
    heinz_gruber
    Chainsaw activated!
     
  3. Driver_X

    Driver_X

    Joined:
    April 15, 2012
    Messages:
    518
    Likes Received:
    991
    Trophy Points:
    473
    In-Game Name:
    Driver_X
    You should write the 'Print' part in a separated line there so the : is not connected to the P from 'print', that way your code wouldn't have been invaded by silly pink faces. Alternatively, you coud have used the 'Code' function in the forums too:

    Code:
    elif (choice, cpu_choice) == (3,2):
    print 'you win'
    rounds += 1
    wins += 1
    I don't really get this thread tho. Did you write that code and want to compare to other people's codes for ideas?
     
  4. iSquared

    iSquared

    • Senior Moderator
    • Gold
    Joined:
    September 11, 2011
    Messages:
    1,117
    Likes Received:
    1,615
    Trophy Points:
    658
    In-Game Name:
    iSquared
    I used to code those on my TI-84 Plus calculator xD
    Those days, man..
     
    Driver_X and asdfjkll2 like this.
  5. jdonovin

    jdonovin

    • Gold
    Joined:
    February 8, 2013
    Messages:
    40
    Likes Received:
    43
    Trophy Points:
    163
    In-Game Name:
    jdonovin
    @Driver_X ya just wanted to compare for ideas
     
  6. Driver_X

    Driver_X

    Joined:
    April 15, 2012
    Messages:
    518
    Likes Received:
    991
    Trophy Points:
    473
    In-Game Name:
    Driver_X
    I have found this: pythontutor.com
    You can test your code there and watch it run step by step.

    I have tried your code and it first gets stuck at this:
    Code:
    x = input('(1)rock, (2)paper, or (3)scissors? :')
    I edited that line into "x = 1" just to test and then the code goes into an endless loop at:
    Code:
    while rounds <= 10: 
    print y 
    x = 1
    choice = x 
    cpu_choice= random.randint(1, 3)
    I know some basic coding and I guess the code needs something to define what block of code that is under the 'while' condition, but I don't know Python enough to fix it lol
    I guess it should be basic formatting/syntax stuff tho, think you could fix that looping thing and maybe the input command too?
     
  7. jdonovin

    jdonovin

    • Gold
    Joined:
    February 8, 2013
    Messages:
    40
    Likes Received:
    43
    Trophy Points:
    163
    In-Game Name:
    jdonovin
  8. legoazurp

    legoazurp

    • Vip
    Joined:
    December 15, 2011
    Messages:
    874
    Likes Received:
    593
    Trophy Points:
    498
    In-Game Name:
    LEGOAP
    How about rock, paper, scissors, lizard, spock?
     

Share This Page