from random import randint
def menu():
while True:
print """ \n\n\n\n\n\n\n
____ ___ ____ _ __ ____ _ ____ _____ ____
| _ \ / _ \ / ___| |/ / | _ \ / \ | _ \| ____| _ \
| |_) | | | | | | ' / | |_) / _ \ | |_) | _| | |_) |
| _ <| |_| | |___| . \ | __/ ___ \| __/| |___| _ <
|_| \_\\___/ \____|_|\_\ |_| /_/ \_\_| |_____|_| \_\
____ ____ ___ ____ ____ ___ ____ ____
/ ___| / ___|_ _/ ___|/ ___| / _ \| _ \/ ___|
\___ \| | | |\___ \\___ \| | | | |_) \___ \
___) | |___ | | ___) |___) | |_| | _ < ___) |
|____/ \____|___|____/|____/ \___/|_| \_\____/\n\n"""
MenuInput = int(raw_input("""
MENU
1. Rock, Paper, Scissors
0. Exit
Your Choice: """))
if MenuInput in range (2):
break
else:
print "\n\tInvalid Entry"
return MenuInput
def match(choice1, choice2):
if choice1 == choice2:
print "You have a match, the computer wins."
raw_input("Press Enter to continue")
def resetScores(user, comScore, gamez):
user = 0
comScore = 0
gamez = 0
def firstChooserWins( chooserChoice, otherChoice ):
if chooserChoice == "Rock" and otherChoice == "Scissors":
return True
elif chooserChoice == "Paper" and otherChoice == "Rock":
return True
elif chooserChoice == "Scissors" and otherChoice == "Paper":
return True
else:
return False
def new(count, countL, game):
if count == game:
print "You win against the computer"
return True
elif countL == game:
print "The Computer has beatin your ass"
return True
else:
print "keep playing to win"
return False
def same(a,b):
if same(countWins, games):
return False
if same(countLost, games):
return True
def playGame():
choice = { 1:"Rock", 2:"Paper", 3:"Scissors" }
countWins = 0
countLost = 0
totalGames = countWins + countLost
if totalGames > 0:
return False
com = "The Computer has won\nThe Computer has won\nThe Computer has won\n"
you = "You have beatin the computer, congratulations\nYou have beatin the computer, congratulations\nYou have beatin the computer, congratulations\n"
while menu() == 1:
if totalGames == 0:
userBestOf = float(raw_input("""
How many games would you like to
play best of with the computer? """))
Avg = userBestOf / 2
games = Avg + 1
print "\tFirst player to %d Wins! " %games
playerPick = int(raw_input("""
Enter choice:
0 : Quit
1 : Rock
2 : Paper
3 : Scissors
Your choice : """))
if playerPick == 0:
break
if playerPick not in choice.keys():
print "\tInvalid choice"
continue
playerChoice = choice[playerPick]
computerChoice = choice[randint(1,3)]
print "\tYou chose %s, the computer chose %s" % ( playerChoice, computerChoice )
if firstChooserWins( playerChoice, computerChoice ):
print "\tYou have won this round!"
countWins += 1
else:
print "\tYou lose!"
countLost += 1
totalGames += 1
if match(playerChoice, computerChoice) == 1:
countLost - 1
return countLost
print "\tYou have Won: ",countWins
print "\tComputer has Won: ",countLost
print "\tTotal Games: ",totalGames
print "\tFirst player to %d Wins! " %games
print "\tKeep playing, first to %d wins." % games
if countWins == games:
print you
raw_input("Press Enter to exit")
resetScores(countWin, countLost, games)
if countLost == games:
print com
raw_input("Press Enter to exit")
resetScores(countWin, countLost, games)
raw_input("\n\tPress Enter to continue\n\n\n\n")
def main():
playGame()
main()
Ive written this program and it works correctly until it get to the player playing another game against the computer
the loop does not work i think
Any help would be great
Thanks