Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # Coded by: Matthew Schaney
- # Copyright (C) <2011> <Matthew Schaney>
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation, either version 3 of the License, or
- # (at your option) any later version.
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- # You should have received a copy of the GNU General Public License
- # along with this program. If not, see <http://www.gnu.org/licenses/>
- # Version 1.0
- # A simple Rock Paper Scissors game. You must have Python installed, to run simply go to a terminal and once in the directory that the code is in type: "python NAME" <--- NAME = whatever you named the code.
- # # # IMPORTS OS, WHICH I USE TO CLEAR THE SCREEN, RANDOM TO GET THE COMPUTER'S SELECTION, AND GETPASS FOR USERNAME AND HIDING USER CHOICES
- import os, random, getpass
- os.system("clear")
- # # # GETS THE USERNAME FROM THE SYSTEM AND ASSIGNS IT TO THE VARIABLE 'username'
- username = getpass.getuser()
- # # # THE INPUT THAT IS USED TO DETERMINE WETHER IT IS SINGLE PLAYER OR NOT
- print "Hello,", username, "\b, would you like to play against a computer or another person?"
- singleOrNot = int(raw_input("(1) Computer\n(2) Multiplayer\n\n---> "))
- # # # IF IT IS 1, WHICH MEANS SINGLE PLAYER, THEN IT RANDOMIZES A NUMBER AND CALCULATES THE CHANGES
- if singleOrNot == 1:
- os.system("clear")
- # # # THE COLORS DEFINITIONS
- normal = '\033[0m'
- bold = '\033[1m'
- lose = '\033[91m'
- win = '\033[92m'
- tie = '\033[93m'
- # # # GENERATES A RANDOM NUMBER BETWEEN 0-2
- computerSelc = random.randrange(3)
- # 0 = ROCK
- # 1 = PAPER
- # 2 = SCISSORS
- # # # GETS YOUR SELECTION
- playerSelc = int(raw_input("WHICH ONE WOULD YOU LIKE?\n(1) Rock\n(2) Paper\n(3) Scissors\n\n---> "))
- # # # THIS BASICALLY IS ALOT OF IF'S THAT MATCH UP THE DIFFERENT POINTS
- if playerSelc == 1:
- if computerSelc == 0:
- print "\n\n", bold, tie, "\b\bTie Game.", normal
- if computerSelc == 1:
- print "\n\n", bold, lose, "\b\bPaper covers Rock, you lose.", normal
- if computerSelc == 2:
- print "\n\n", bold, win, "\b\bRock smashes Scissors, you win!", normal
- if playerSelc == 2:
- if computerSelc == 0:
- print "\n\n", bold, win, "\b\bPaper covers Rock, you win!", normal
- if computerSelc == 1:
- print "\n\n", bold, tie, "\b\bTie Game.", normal
- if computerSelc == 2:
- print "\n\n", bold, lose, "\b\bScissors cut paper, you lose.", normal
- if playerSelc == 3:
- if computerSelc == 0:
- print "\n\n", bold, lose, "\b\bRock smashes Scissors, you lose.", normal
- if computerSelc == 1:
- print "\n\n", bold, win, "\b\bScissors cut paper, you win!", normal
- if computerSelc == 2:
- print "\n\n", bold, tie, "\b\bTie Game.", normal
- # # # BASICALLY THE EXACT SAME STUFF AS ABOVE NO RANDOM NUMBER INSTEAD IT IS AN INPUTED NUMBER FROM BOTH PLAYERS
- if singleOrNot == 2:
- os.system("clear")
- # # # THERE ARE DIFFERENT COLORS COMPARED TO ABOVE
- normal = '\033[0m'
- bold = '\033[1m'
- two = '\033[91m'
- one = '\033[34m'
- tie = '\033[93m'
- print "PLAYER", bold, one, "\b\bONE", normal, "\b\b: WHICH ONE WOULD YOU LIKE?\n(1) Rock\n(2) Paper\n(3) Scissors\n\n"
- player1Selc = int(getpass.getpass("---> "))
- os.system("clear")
- print "PLAYER", bold, two, "\b\bTWO", normal, "\b\b: WHICH ONE WOULD YOU LIKE?\n(1) Rock\n(2) Paper\n(3) Scissors\n\n"
- player2Selc = int(getpass.getpass("---> "))
- # # # SAME CALCULATION SYSTEM; USES DIFFERENT VARIABLE SENSE IT IS A PLAYER, NOT A COMPUTER
- if player1Selc == 1:
- if player2Selc == 1:
- print "\n\n", bold, tie, "\b\bTie Game.", normal
- if player2Selc == 2:
- print "\n\n", bold, two, "\b\bPaper covers Rock, Player Two wins.", normal
- if player2Selc == 3:
- print "\n\n", bold, one, "\b\bRock smashes Scissors, Player One wins.", normal
- if player1Selc == 2:
- if player2Selc == 1:
- print "\n\n", bold, one, "\b\bPaper covers Rock, Player One wins.", normal
- if player2Selc == 2:
- print "\n\n", bold, tie, "\b\bTie Game.", normal
- if player2Selc == 3:
- print "\n\n", bold, two, "\b\bScissors cut paper, Player Two wins.", normal
- if player1Selc == 3:
- if player2Selc == 1:
- print "\n\n", bold, two, "\b\bRock smashes Scissors, Player Two wins.", normal
- if player2Selc == 2:
- print "\n\n", bold, one, "\b\bScissors cut paper, Player One wins.", normal
- if player2Selc == 3:
- print "\n\n", bold, tie, "\b\bTie Game.", normal
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement