summaryrefslogtreecommitdiff
path: root/rockpaperscissors.py
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2023-11-09 20:19:38 +0800
committerlittleblack111 <littleblack11111@gmail.com>2023-11-09 20:19:38 +0800
commit01a84bc0d8625d3c03bff8270889bf4083b4ee6f (patch)
tree927af0b8675d4532c42f043ae1bb0de204d0e043 /rockpaperscissors.py
parent6b683aa528f7d8c98f476370ed05989601b95dee (diff)
name change
Diffstat (limited to 'rockpaperscissors.py')
-rw-r--r--rockpaperscissors.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/rockpaperscissors.py b/rockpaperscissors.py
new file mode 100644
index 0000000..b647a86
--- /dev/null
+++ b/rockpaperscissors.py
@@ -0,0 +1,41 @@
+import random
+
+def game():
+ print("choose:\n1 - rock \n2 - paper \n3 - sissor")
+ player = int(input("> "))
+ bot = random.randint(1,3)
+ if player > bot and abs(player-bot) != 2:
+ return 1
+ else:
+ return 0
+
+print("Win two out of three games(1) or decide the outcome in one game(2)?")
+mode = input("enter a number > ")
+match mode:
+ case "1":
+ resultReal = 1
+ for i in range(3):
+ result = game()
+ if result:
+ print(f"player win this round!")
+ else:
+ print(f"bot win this round!")
+ resultReal = resultReal + result
+ if resultReal <= 2:
+ print("\nbot win the game!")
+ else:
+ print("\nplayer win the game!")
+ case "2":
+ result = game()
+ if result:
+ print(f"player win!")
+ else:
+ print(f"bot win!")
+
+
+from stdlib import *
+from random import randint
+
+def initAnswer() -> int:
+ return randint(1, 3)
+