Skip to content

Commit

Permalink
keep Version 1.0 May 4, 2020
Browse files Browse the repository at this point in the history
  • Loading branch information
hzoo committed May 5, 2020
1 parent d6aac4f commit 970223d
Showing 1 changed file with 0 additions and 125 deletions.
125 changes: 0 additions & 125 deletions rockpaperscissors.py
Expand Up @@ -12,8 +12,6 @@
s-r=4, p2 wins
s-p=2, and p1==s, p1 wins
'''
#version 1.0 May 4, 2020
'''
d={'r':0,'p':2,'s':4}

def loop():
Expand Down Expand Up @@ -77,126 +75,3 @@ def r3():
r0()
else:
print('invalid entry, run script again')
'''
#version 2.0 May 5, 2020
import random
import sys
d={'r':0,'p':2,'s':4}
c=[0,2,4]

def loop():
random.shuffle(c)
a=int(d[input('player 1: ')])
b=int(c[0])
if b==0:
print('computer: r')
elif b==2:
print('computer: p')
elif b==4:
print('computer: s')

if a-b==0:
print('draw\n')
elif a-b==4 or a-b==-2 and a<4:
print('computer wins\n')
else:
print('player 1 wins\n')
loop()

def r0():
random.shuffle(c)
a=int(d[input('player 1: ')])
b=int(c[0])
if b==0:
print('computer: r')
elif b==2:
print('computer: p')
elif b==4:
print('computer: s')
if a-b==0:
r0()
elif a-b==4 or (a-b==-2 and a<4):
r2()
else:
r1()

def r1():
random.shuffle(c)
a=int(d[input('player 1: ')])
b=int(c[0])
if b==0:
print('computer: r')
elif b==2:
print('computer: p')
elif b==4:
print('computer: s')

if a-b==0:
r1()
elif a-b==4 or (a-b==-2 and a<4):
r3()
else:
r=input('player 1 wins!\nplay again? (y/n) ')
if r=='y':
r0()
else:
sys.exit()

def r2():
random.shuffle(c)
a=int(d[input('player 1: ')])
b=int(c[0])
if b==0:
print('computer: r')
elif b==2:
print('computer: p')
elif b==4:
print('computer: s')

if a-b==0:
r2()
elif a-b==4 or (a-b==-2 and a<4):
r=input('computer wins!\nplay again? (y/n) ')
if r=='y':
r0()
else:
sys.exit()
else:
r3()

def r3():
random.shuffle(c)
a=int(d[input('player 1: ')])
b=int(c[0])
if b==0:
print('computer: r')
elif b==2:
print('computer: p')
elif b==4:
print('computer: s')

if a-b==0:
r3()
elif a-b==4 or (a-b==-2 and a<4):
r=input('computer wins!\nplay again? (y/n) ')
if r=='y':
r0()
else:
sys.exit()
else:
r=input('player 1 wins!\nplay again? (y/n) ')
if r=='y':
r0()
else:
sys.exit()

s=input('welcome to the rock-paper-scissors game\n'
'instructions: enter "r" for rock, "p" for paper, and "s" for scissors\n\n'
'for eternity game, type -> 1\nfor best of 3, type -> 2\n')

if s=='1':
loop()
elif s=='2':
r0()
else:
print('invalid entry, run script again')

0 comments on commit 970223d

Please sign in to comment.