|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +""" |
| 3 | +Created on Mon Aug 17 14:24:23 2020 |
| 4 | +
|
| 5 | +@author: Gulshan |
| 6 | +""" |
| 7 | +# Function rock_paper_scissor---> |
| 8 | +def rock_paper_scissor(num1,num2,bit1,bit2): |
| 9 | + play_pos1=int(num1[bit1])%3 #Play Position For Player 1 |
| 10 | + play_pos2=int(num2[bit2])%3 #Play Position For Player 2 |
| 11 | + if(player_one[play_pos1]==player_two[play_pos2]): |
| 12 | + print("Draw") |
| 13 | + elif(player_one[play_pos1]=="Rock" and player_two[play_pos2]=="Scissor"): |
| 14 | + print("Player one wins!!") |
| 15 | + elif(player_one[play_pos1]=="Rock" and player_two[play_pos2]=="Paper"): |
| 16 | + print("Player two wins!!") |
| 17 | + elif(player_one[play_pos1]=="Paper" and player_two[play_pos2]=="Scissor"): |
| 18 | + print("Player two wins!!") |
| 19 | + elif(player_one[play_pos1]=="Paper" and player_two[play_pos2]=="Rock"): |
| 20 | + print("Player one wins!!") |
| 21 | + elif(player_one[play_pos1]=="Scissor" and player_two[play_pos2]=="Rock"): |
| 22 | + print("Player two wins!!") |
| 23 | + elif(player_one[play_pos1]=="Scissor" and player_two[play_pos2]=="Paper"): |
| 24 | + print("Player one wins!!") |
| 25 | + |
| 26 | +# Main Function To Execute Rock Paper Scissor |
| 27 | +if __name__ == '__main__': |
| 28 | + player_one={0:'Rock',1:'Paper',2:'Scissor'} |
| 29 | + player_two={0:'Paper',1:'Rock',2:'Scissor'} |
| 30 | + while(1): |
| 31 | + num1=input("Player one, Enter your choice ") |
| 32 | + num2=input("Player two, Enter your choice ") |
| 33 | + bit1=int(input("Player one, Enter the secret bit position ")) |
| 34 | + bit2=int(input("Player two, Enter the secret bit position ")) |
| 35 | + rock_paper_scissor(num1,num2,bit1,bit2) |
| 36 | + ch=input("Do you want to continue? y/n ") |
| 37 | + if(ch=='n'): |
| 38 | + break |
| 39 | + |
| 40 | + |
| 41 | +''' |
| 42 | +Output Implementation: |
| 43 | +
|
| 44 | +Player one, Enter your choice 123 |
| 45 | +Player two, Enter your choice 567 |
| 46 | +Player one, Enter the secret bit position 0 |
| 47 | +Player two, Enter the secret bit position 1 |
| 48 | +Draw |
| 49 | +
|
| 50 | +Do you want to continue? y/n y |
| 51 | +Player one, Enter your choice 012 |
| 52 | +Player two, Enter your choice 234 |
| 53 | +Player one, Enter the secret bit position 1 |
| 54 | +Player two, Enter the secret bit position 2 |
| 55 | +Player one wins!! |
| 56 | +
|
| 57 | +Do you want to continue? y/n y |
| 58 | +Player one, Enter your choice 345 |
| 59 | +Player two, Enter your choice 012 |
| 60 | +Player one, Enter the secret bit position 0 |
| 61 | +Player two, Enter the secret bit position 2 |
| 62 | +Player one wins!! |
| 63 | +
|
| 64 | +''' |
0 commit comments