From 970223d8dbbc62a01d2fd8e151c8e74a78bd0b3d Mon Sep 17 00:00:00 2001 From: Henry Zhu Date: Tue, 5 May 2020 18:48:47 -0400 Subject: [PATCH] keep Version 1.0 May 4, 2020 --- rockpaperscissors.py | 125 ------------------------------------------- 1 file changed, 125 deletions(-) diff --git a/rockpaperscissors.py b/rockpaperscissors.py index de09708..1eb27dc 100644 --- a/rockpaperscissors.py +++ b/rockpaperscissors.py @@ -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(): @@ -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')