Skip to content

Commit e38d7e7

Browse files
authored
Add two-player scoring system with time limit
Implement a scoring system for a two-player timed game of Bar Billliards. This is just stage 1 of the project so I've simplified it as much as I can just to get it to working. I'll add more functionality and detail later in the development proccess.
1 parent 84c3f4e commit e38d7e7

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

BB_AutoScore_Stage1.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import time
2+
# from datetime import datetime
3+
# import math
4+
5+
6+
P1Score = int(0)
7+
P2Score = int(0)
8+
9+
10+
start_time = time.time()
11+
duration = 100
12+
13+
P1_name = str(input("Enter Player 1 Name: "))
14+
P2_name = str(input("Enter Player 2 Name: "))
15+
16+
17+
def P1Turn(P1Score):
18+
Break = int(0)
19+
print(f"{P1_name} turn")
20+
print(f"What did {P1_name} Score?")
21+
Break = int(input())
22+
23+
if Break == 1:
24+
P1Score = 0 # Black mushroom
25+
26+
else:
27+
P1Score = P1Score + Break
28+
29+
print(f"Current {P1_name} score = {P1Score}")
30+
return P1Score
31+
32+
33+
def P2Turn(P2Score):
34+
Break = int(0)
35+
print(f"{P2_name} turn")
36+
print(f"What did {P2_name} Score?")
37+
Break = int(input())
38+
if Break == 1:
39+
P2Score = 0 # Black Mushroom
40+
41+
else:
42+
P2Score = P2Score + Break
43+
44+
print(f"Current {P2_name} score = {P2Score}")
45+
return P2Score
46+
47+
48+
while (time.time() - start_time) < duration:
49+
print(P1Score)
50+
P1Score = P1Turn(P1Score)
51+
print(P2Score)
52+
P2Score = P2Turn(P1Score)
53+
54+
else:
55+
if P1Score > P2Score:
56+
print(f"{P1_name} is the winner!")
57+
print(f"{P1_name} score : {P1Score}")
58+
print(f"Looser {P2_name} score : {P2Score}")
59+
elif P2Score > P1Score:
60+
print(f"{P2_name} is the winner!")
61+
print(f"{P2_name} score : {P2Score}")
62+
print(f"Looser {P1_name} score : {P1Score}")
63+
else:
64+
print(f"{P1_name} and {P2_name} have drawn the game")
65+
print(f"Both loosers scored {P1Score}")
66+
67+
68+
print("End of program")

0 commit comments

Comments
 (0)