#!U:\Pycharm\Game.py
# Rock Paper
import random
import time
dragon = 1
spear = 2
human = 3
names = {dragon: "Dragon", spear: " Spear", human: "Human"}
rules = {dragon: human, spear: dragon, human: spear}
player_score = 0
computer_score = 0
def start():
print "Want to play a game?"
while game():
pass
scores()
def game():
player = move()
computer = random.randint(1,3)
result(player, computer)
return play_again()
# noinspection PyUnreachableCode,PyUnreachableCode
def move():
while True:
print
player = raw_input("Dragon = 1\nSpear = 2\nHuman = 3\nPick a number already, peon!: ")
try:
player = int(player)
if player in (1,2,3):
return player
except ValueError:
pass
print "You really can't count? Enter a number 1, 2 or 3"
def result(player, computer):
print "1..."
time.sleep(1)
print "2..."
time.sleep(1)
print "3!"
time.sleep(0.5)
print "Computer threw [0]!".format(names[computer])
global player_score, computer_score
if player == computer:
print "can't even beat an AI."
else:
if rules[player] == computer:
print "Winner Winner Chicken Dinner."
player_score += 1
else:
print "The computer just beat you, Skynet is upon us."
computer_score += 1
def play_again():
answer = raw_input("want to come and play? y/n: ")
if answer in ("y", "Y", "yes", "Yes", "of course!"):
return answer
else:
print "Thank you very much for playing Aaron Sans game. get reked noob!"
def scores():
global player_score, computer_score
print "HIGH SCORES "
print "Player: ", player_score
print "Computer: ", computer_score
if __name__ == '__main__':
start()
****************************************************
Okay so when I run the file it in python
Want to play a game?
Dragon = 1
Spear = 2
Human = 3
Pick a number already, peon!:
as soon as I input any number, it loops and says the same text.
I think the input is incorrect as Pycharm stats noinspection PyUnreachableCode,PyUnreachableCode if so how do I change the code?
What am I doing wrong?
# Rock Paper
import random
import time
dragon = 1
spear = 2
human = 3
names = {dragon: "Dragon", spear: " Spear", human: "Human"}
rules = {dragon: human, spear: dragon, human: spear}
player_score = 0
computer_score = 0
def start():
print "Want to play a game?"
while game():
pass
scores()
def game():
player = move()
computer = random.randint(1,3)
result(player, computer)
return play_again()
# noinspection PyUnreachableCode,PyUnreachableCode
def move():
while True:
player = raw_input("Dragon = 1\nSpear = 2\nHuman = 3\nPick a number already, peon!: ")
try:
player = int(player)
if player in (1,2,3):
return player
except ValueError:
pass
print "You really can't count? Enter a number 1, 2 or 3"
def result(player, computer):
print "1..."
time.sleep(1)
print "2..."
time.sleep(1)
print "3!"
time.sleep(0.5)
print "Computer threw [0]!".format(names[computer])
global player_score, computer_score
if player == computer:
print "can't even beat an AI."
else:
if rules[player] == computer:
print "Winner Winner Chicken Dinner."
player_score += 1
else:
print "The computer just beat you, Skynet is upon us."
computer_score += 1
def play_again():
answer = raw_input("want to come and play? y/n: ")
if answer in ("y", "Y", "yes", "Yes", "of course!"):
return answer
else:
print "Thank you very much for playing Aaron Sans game. get reked noob!"
def scores():
global player_score, computer_score
print "HIGH SCORES "
print "Player: ", player_score
print "Computer: ", computer_score
if __name__ == '__main__':
start()
****************************************************
Okay so when I run the file it in python
Want to play a game?
Dragon = 1
Spear = 2
Human = 3
Pick a number already, peon!:
as soon as I input any number, it loops and says the same text.
I think the input is incorrect as Pycharm stats noinspection PyUnreachableCode,PyUnreachableCode if so how do I change the code?
What am I doing wrong?