mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-22 07:10:42 -08:00
MAINT: Apply pre-commit
Remove byte-order-marker pre-commit check as there would be many adjustments necessary
This commit is contained in:
@@ -2,13 +2,14 @@ import random
|
||||
|
||||
|
||||
def print_n_whitespaces(n: int):
|
||||
print(" "*n, end="")
|
||||
print(" " * n, end="")
|
||||
|
||||
|
||||
def print_n_newlines(n: int):
|
||||
for _ in range(n):
|
||||
print()
|
||||
|
||||
|
||||
print_n_whitespaces(32)
|
||||
print("BULLSEYE")
|
||||
print_n_whitespaces(15)
|
||||
@@ -18,10 +19,26 @@ print("IN THIS GAME, UP TO 20 PLAYERS THROW DARTS AT A TARGET")
|
||||
print("WITH 10, 20, 30, AND 40 POINT ZONES. THE OBJECTIVE IS")
|
||||
print("TO GET 200 POINTS.")
|
||||
print()
|
||||
print("THROW",end="");print_n_whitespaces(20);print("DESCRIPTION", end="");print_n_whitespaces(45);print("PROBABLE SCORE")
|
||||
print(" 1",end="");print_n_whitespaces(20);print("FAST OVERARM",end="");print_n_whitespaces(45);print("BULLSEYE OR COMPLETE MISS")
|
||||
print(" 2",end="");print_n_whitespaces(20);print("CONTROLLED OVERARM",end="");print_n_whitespaces(45);print("10, 20 OR 30 POINTS")
|
||||
print(" 3",end="");print_n_whitespaces(20);print("UNDERARM",end="");print_n_whitespaces(45);print("ANYTHING")
|
||||
print("THROW", end="")
|
||||
print_n_whitespaces(20)
|
||||
print("DESCRIPTION", end="")
|
||||
print_n_whitespaces(45)
|
||||
print("PROBABLE SCORE")
|
||||
print(" 1", end="")
|
||||
print_n_whitespaces(20)
|
||||
print("FAST OVERARM", end="")
|
||||
print_n_whitespaces(45)
|
||||
print("BULLSEYE OR COMPLETE MISS")
|
||||
print(" 2", end="")
|
||||
print_n_whitespaces(20)
|
||||
print("CONTROLLED OVERARM", end="")
|
||||
print_n_whitespaces(45)
|
||||
print("10, 20 OR 30 POINTS")
|
||||
print(" 3", end="")
|
||||
print_n_whitespaces(20)
|
||||
print("UNDERARM", end="")
|
||||
print_n_whitespaces(45)
|
||||
print("ANYTHING")
|
||||
print()
|
||||
|
||||
M = 0
|
||||
@@ -37,7 +54,7 @@ for I in range(1, 21):
|
||||
|
||||
N = int(input("HOW MANY PLAYERS? "))
|
||||
A = {}
|
||||
for I in range(1, N+1):
|
||||
for I in range(1, N + 1):
|
||||
Name = input("NAME OF PLAYER #")
|
||||
A[I] = Name
|
||||
|
||||
@@ -45,29 +62,29 @@ while M == 0:
|
||||
R = R + 1
|
||||
print()
|
||||
print(f"ROUND {R}---------")
|
||||
for I in range(1, N+1):
|
||||
for I in range(1, N + 1):
|
||||
print()
|
||||
while True:
|
||||
T = int(input(f"{A[I]}'S THROW? "))
|
||||
if T < 1 or T > 3:
|
||||
print("INPUT 1, 2, OR 3!")
|
||||
else:
|
||||
else:
|
||||
break
|
||||
if T == 1:
|
||||
P1=.65
|
||||
P2=.55
|
||||
P3=.5
|
||||
P4=.5
|
||||
P1 = 0.65
|
||||
P2 = 0.55
|
||||
P3 = 0.5
|
||||
P4 = 0.5
|
||||
elif T == 2:
|
||||
P1=.99
|
||||
P2=.77
|
||||
P3=.43
|
||||
P4=.01
|
||||
P1 = 0.99
|
||||
P2 = 0.77
|
||||
P3 = 0.43
|
||||
P4 = 0.01
|
||||
elif T == 3:
|
||||
P1=.95
|
||||
P2=.75
|
||||
P3=.45
|
||||
P4=.05
|
||||
P1 = 0.95
|
||||
P2 = 0.75
|
||||
P3 = 0.45
|
||||
P4 = 0.05
|
||||
U = random.random()
|
||||
if U >= P1:
|
||||
print("BULLSEYE!! 40 POINTS!")
|
||||
@@ -78,7 +95,7 @@ while M == 0:
|
||||
elif U >= P3:
|
||||
print("20-POINT ZONE")
|
||||
B = 20
|
||||
elif U >= P4:
|
||||
elif U >= P4:
|
||||
print("WHEW! 10 POINTS.")
|
||||
B = 10
|
||||
else:
|
||||
@@ -86,15 +103,15 @@ while M == 0:
|
||||
B = 0
|
||||
S[I] = S[I] + B
|
||||
print(f"TOTAL SCORE = {S[I]}")
|
||||
for I in range(1, N+1):
|
||||
for I in range(1, N + 1):
|
||||
if S[I] > 200:
|
||||
M = M+1
|
||||
M = M + 1
|
||||
W[M] = I
|
||||
|
||||
|
||||
print()
|
||||
print("WE HAVE A WINNER!!")
|
||||
print()
|
||||
for I in range(1, M+1):
|
||||
for I in range(1, M + 1):
|
||||
print(f"{A[W[I]]} SCORED {S[W[I]]} POINTS.")
|
||||
print()
|
||||
print("THANKS FOR THE GAME.")
|
||||
print("THANKS FOR THE GAME.")
|
||||
|
||||
Reference in New Issue
Block a user