Project Python: Rock Paper Scissors [Updated]

You might have heard of Python, it’s a type of programming language where you get to program websites and games. Today I have made a game, rock, paper, scissors, it might be familiar to you ^__^……

Screen Shot 2017-01-29 at 8.25.06 AM.png

When you look at the right side of the screenshot, you would see the terminal, where I play the game by calling the program and start playing. On the left side, is the behind – the  – scenes of the game, where I program the game to make it work the way it works. It was a bit challenging when I started this but when I finally finished the whole program, it was fun!

[Updated Part]

Here is the rest of the code for those who would want to experiment and have fun!!!


from random import randint

moves = [‘Rock’, ‘Paper’, ‘Scissors’]
def ask_move(player = False):
if player:
return moves.index(moves[int(raw_input(“Pick a move, 1: %s, 2: %s, 3: %s”
% (moves[0], moves[1], moves[2]))) – 1]) + 1
else:
return randint(1, 3)
def calculate_score(p1, p2):
movescore = p1 -p2
if movescore == 0:
print(“Tie!”)
elif movescore in (1, -2):
print(“Win!”)
else:
print(“You lose!”)

if __name__ == “__main__”:
print(“Welcome to the Rock, Paper, Scissors game!”)
while True:
print(“Player 1:\n”)
one = ask_move(True)
two = ask_move()
calculate_score(one, two)
try:
break_ = raw_input(“Would you like to play again?\nEnter [1] if you would like to, else press enter.”)
if 1 == int(break_):
print(“Thank you for playing!”)
break
except ValueError:
print(“Ok, here we go again\n”)


You guys will need to indent most of these. Python has a sort of rule where if the indentention isn’t proper, your code will not work. Experiment. Research. Have fun!

Yours truly,

L.O.A.S.H

Advertisements

3 Comments

  1. you are prolific! but im glad i subscribed. if you post the rest of your code i can work on the rest of this translation. here is a taste:

    function calculate_score p1 p2
        movescore = p1 minus p2
        ifequal movescore 0
            x "Tie!"        print    return x
            fig
    
        ck 1  arr  plus -2    # create list
        forin x ck
            ifequal movescore x
                x "Win!"    print    return x
                fig
            nextin
    
        x "You lose!"       print    return x
        fig
    
    nem = 0
    python
        if __name__ == "__main__": nem = 1
    fig
    
    iftrue nem
        now "Welcome to the Rock, Paper, Scissors game!"  print
        try
            while
                now "Player1:\n"  print lineinput
                wend
        except 
            pass
            resume
    
        now calculate_score 5 5
        now calculate_score 5 4
        now calculate_score 5 7
        now calculate_score 5 8
        fig

    Like

Comments are closed.