|
| 1 | +## stone paper seisor game ## |
| 2 | + |
| 3 | +import random |
| 4 | + |
| 5 | +dict={"s":1, "p":0, "si":-1,} |
| 6 | +revdict={1:"stone",0:"paper",-1:"scissor"} |
| 7 | + |
| 8 | +def game_intro(): |
| 9 | + print("="*41) |
| 10 | + print("🎮 Welcome to Stone, Paper, Scissor Game!") |
| 11 | + print("="*41) |
| 12 | + print("-"*42) |
| 13 | + print("INSTRUCTION:") |
| 14 | + print("🏁 The Tournament is of 10 rounds") |
| 15 | + print("Choose from (s=stone, p=paper , si=scissor)") |
| 16 | + print("Type 'exit' to leave the game") |
| 17 | + print("-"*42) |
| 18 | + |
| 19 | +def play_game(): |
| 20 | + rounds = 0 |
| 21 | + max_rounds = 10 |
| 22 | + wins=0 |
| 23 | + losses=0 |
| 24 | + draws=0 |
| 25 | + |
| 26 | + while True: |
| 27 | + if rounds >= max_rounds: |
| 28 | + print("\n"+"🏁"*31) |
| 29 | + print("🏁 10 rounds completed.") |
| 30 | + print(f"✅ Wins: {wins}") |
| 31 | + print(f"❌ Losses: {losses}") |
| 32 | + print(f"🤝 Draws: {draws}") |
| 33 | + if(wins>losses): |
| 34 | + print(f"📊 Final decision: you win the tournament by {wins} wins.") |
| 35 | + elif(wins<losses): |
| 36 | + print(f"📊 Final decision: you lose the tournament by {losses} losses.") |
| 37 | + else: |
| 38 | + print(f"📊 Final decision: The tournament is draw by {wins} wins & {losses} losses") |
| 39 | + print(f"👋 Thankyou you for playing!") |
| 40 | + print("🏁"*31) |
| 41 | + break |
| 42 | + print("\n") |
| 43 | + comp=random.choice([1,0,-1]) |
| 44 | + youstr=input(f"Round {rounds+1} - Enter your choice:").strip().lower() |
| 45 | + |
| 46 | + if(youstr=="exit"): |
| 47 | + print("\n"+"🏁"*31) |
| 48 | + print("Exited manually.") |
| 49 | + print(f"✅ Wins: {wins}") |
| 50 | + print(f"❌ Losses: {losses}") |
| 51 | + print(f"🤝 Draws: {draws}") |
| 52 | + if(wins>losses): |
| 53 | + print(f"📊 Final decision: you win the tournament by {wins} wins.") |
| 54 | + elif(wins<losses): |
| 55 | + print(f"📊 Final decision: you lose the tournament by {losses} losses.") |
| 56 | + elif(wins==losses): |
| 57 | + print(f"📊 Final decision: The tournament is draw by {wins} wins & {losses} losses") |
| 58 | + print(f"👋 Thankyou you for playing!") |
| 59 | + print("🏁"*31) |
| 60 | + break |
| 61 | + |
| 62 | + |
| 63 | + if youstr not in dict: |
| 64 | + print("❌ Invalid input. Please enter 's=stone', 'p=paper', or 'si=scissor'.") |
| 65 | + continue |
| 66 | + |
| 67 | + you= dict[youstr] |
| 68 | + print(f"🧑 Your choice: {revdict[you]}\n💻 Computer's choice: {revdict[comp]}") |
| 69 | + |
| 70 | + if (comp==you): |
| 71 | + print("it's a draw 🤝.") |
| 72 | + draws+=1 |
| 73 | + elif (comp==1 and you==0)or\ |
| 74 | + (comp==0 and you==-1)or\ |
| 75 | + (comp==-1 and you==1): |
| 76 | + print("you win! ✅") |
| 77 | + wins+=1 |
| 78 | + else: |
| 79 | + print("you lose! ❌") |
| 80 | + losses+=1 |
| 81 | + |
| 82 | + rounds += 1 |
| 83 | + |
| 84 | +def replay(): |
| 85 | + while True: |
| 86 | + reply=input("Do you want to play again? (yes/no): ").strip().lower() |
| 87 | + if reply=="yes": |
| 88 | + return True |
| 89 | + elif reply=="no": |
| 90 | + print("See you again!") |
| 91 | + return False |
| 92 | + else: |
| 93 | + print("Please enter yes or no.") |
| 94 | + |
| 95 | +while True: |
| 96 | + game_intro() |
| 97 | + play_game() |
| 98 | + if not replay(): |
| 99 | + break |
| 100 | + |
0 commit comments