Python Forum
Rock Paper Scissors game
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rock Paper Scissors game
#1
Hello all!
I have to make a rock paper scissors game in python but it has very specific needs.
It has to have This exact Main Menu:
  1. See the Rules

  2. Play against the computer

  3. Play a two player game

  4. Quit
This exact Weapon Menu for both one player and two player game to choose weapon:
  1. Rock

  2. Paper

  3. Scissors

  4. Return to Main Menu 
There also has to be a score keeper for each gamer type that is displayed after each game is played.
I know I'm asking for a lot but please help! i will post what i have so far.

im using python 3.6 also if that matters.

from random import randint


def mainMenu():
    #intro and menu
    print("Welcom to Rock, Paper Scissors!\n")
    print("MENU")
    print("(1) See Rules")
    print("(2) Single Player")
    print("(3) Two Player")
    print("(4) Exit\n")

    #choosing which menu option
    choice = input("")
    
    if choice == "1":
        print(rules())
    elif choice == "2":
        singlePlayer()
    elif choice == "3":
        twoPlayer()
    elif choice == "4":
        endProgram()
        
    #rules module    
def rules():
    print("RULES")
    print("Paper Covers Rock, Rock Smashes Scissors, Scissors Cuts Paper\n")
    
    mainMenu()

def weaponMenu():
    print("Choose your weapon!")
    print("(1) Rock")
    print("(2) Paper")
    print("(3) Scissors")
    print("(4) Main Menu")
    
def singlePlayer():

    #create a list of play options
    moves = ["rock", "paper", "scissors"]
 
    #assign a random play to the computer
    computer = moves[randint(0,2)]
 
    #set player to False
    player = False

    while player == False:
    #set player to True
        player = input("Choose rock, paper, or scissors! ")
        if player == computer:
                print("Tie!")
                print(score)
                
        elif player == "rock":
            if computer == "paper":
                print("You lose!", computer, "covers", player)
                computerScore = computerScore + 1
                print(score)
                return computerScore
            else:
                print("You win!", player, "smashes", computer)
        elif player == "paper":
            if computer == "scissors":
                print("You lose!", computer, "cut", player)
            else:
                print("You win!", player, "covers", computer)
        elif player == "scissors":
            if computer == "rock":
                print("You lose...", computer, "smashes", player)
            else:
                print("You win!", player, "cut", computer)
        else:
            print("That's not a valid play. Check your spelling!")


def twoPlayer():
    print("Choose Rock Paper or Scissors, try to hide your choice!\n")
    player1 = input("Player 1 : ")
    player2 = input("Player 2 : ")
    print("")
    

    if (player1 == 'rock' and player2 == 'scissors'):
        print ("Player 1 wins.")

    elif (player1 == 'rock' and player2 == 'rock'):
        print ("Tie")

    elif (player1 == 'scissors' and player2 == 'paper'):
        print ("Player 1 wins.")

    elif (player2 == 'scissors' and player2 == 'scissors'):
        print ("Tie")

    elif (player1 == 'paper' and player2 == 'paper'):
        print ("Tie")

    elif (player1 == 'paper' and player2 == 'scissors'):
        print ("Player 2 wins.")

    elif (player1 == 'rock'and player2 == 'paper'):
        print ("Player 2 wins.")

    elif (player1 == 'paper' and player2 == 'rock'):
        print ("Player 1 wins.")

    elif (player1 == 'scissors' and player2 == 'rock'):
        print ("Player 2 wins.")


def endProgram():
    
    end = input("Would you like to end the program? (yes or no) ")
    if end == "no":
        mainMenu()
    else:
        quit()

mainMenu()
    
Reply
#2
Nice Game .But can you assign a return to menu feature?

Output:
Welcom to Rock, Paper Scissors! MENU (1) See Rules (2) Single Player (3) Two Player (4) Exit 3 Choose Rock Paper or Scissors, try to hide your choice! Player 1 : rock Player 2 : rock Tie >>> 

Nice Game .But can you assign a return to menu feature?
it will be nice if the game works that way



Output:
Welcom to Rock, Paper Scissors! MENU (1) See Rules (2) Single Player (3) Two Player (4) Exit 3 Choose Rock Paper or Scissors, try to hide your choice! Player 1 : rock Player 2 : rock Tie >>> 

(Apr-27-2017, 08:36 AM)codeobri Wrote: print("Welcom to Rock, Paper Scissors!\n")
There is a Typo in the intro mesage
Reply
#3
I'm just going to go over singlePlayer. First, you need to make use of weaponMenu. I would put the input in weaponMenu, and return the value from there. Something like:

return input('What is your choice?')
Then you will need to use and assign that in singlePlayer:

player = weaponMenu()
Then in singlePlayer, your loop termination needs to work with weaponMenu. I would set up the loop this way:

while True:
    # your code here
    if player == '4':
        break
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#4
Thank you both for the feedback! I will try this shortly then ill have to find a way to incorporate the weapon menu in 2 player.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  I attempted to make a rock paper scissors bot for homework Intellectual11 3 2,866 Jun-24-2021, 08:00 PM
Last Post: deanhystad
Question Rock, paper, scissors spelling error banidjamali 6 3,138 Jan-19-2021, 02:51 PM
Last Post: banidjamali
  Rock, Paper, Scissors Game kramon19 2 5,290 Jan-10-2020, 08:18 AM
Last Post: perfringo
  I need help with a python Rock Paper Scissors game urgently. Riff_Raff 3 5,750 Dec-05-2018, 09:13 PM
Last Post: nilamo
  Rock, Paper, Scissors Advanced that saves, loads, and keeps statistics EvanCahill 0 5,162 Jul-21-2018, 07:32 PM
Last Post: EvanCahill
  Rock Paper Scissors Warmlawpk441 4 4,970 Oct-11-2017, 10:55 AM
Last Post: gruntfutuk
  Rock paper scissors game samiraheen 3 6,305 Oct-03-2017, 07:07 PM
Last Post: buran
  The Python Book altered rock paper scissors Python_Noob 0 2,873 Sep-18-2017, 06:13 AM
Last Post: Python_Noob
  HELP---problems with rock paper scissors games kalt91 2 4,069 Sep-15-2017, 04:51 PM
Last Post: micseydel
  Rock, Paper, Scissors game help.. hentera 3 4,996 May-19-2017, 10:56 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020