-
Notifications
You must be signed in to change notification settings - Fork 0
/
Final Project.py
62 lines (57 loc) · 1.7 KB
/
Final Project.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import random
import math
gameName = str(input("What is the name of the game being played? "))
#print (gameName)
players = []
matchups = {}
numMatches = 0
roundNumber = 1
i = 0
while i != 'N':
players.append(input("Enter a player's name. "))
print (players)
i = str(input('Are there more players? (Y/N) '))
numPlayers = int(len(players))
print(numPlayers, "players in the tournament!", '\n')
numMatches = math.trunc(numPlayers ** 1/2)
def matchUp(players, numMatches, numPlayers):
g = 0
# print (numMatches, "matches in round", roundNumber)
if numMatches != numPlayers / 2:
byPlayer = random.choice(players)
players.remove(byPlayer)
# print(players)
print ("Free round given to", byPlayer, '\n')
numPlayers = len(players)
while g != (len(players) / 2) + g:
# print ('Number of players =', len(players))
n = 0
buffer = (random.sample(players,2))
# print (buffer)
matchups.update({g:buffer})
while n != len(buffer):
players.remove(buffer[n])
n += 1
# print('Matchups =',matchups)
# print('Players =', players)
g += 1
print ("Round", roundNumber, "Matches are: ")
print ('_____________________________', '\n')
# print (matchups)
# print('g value is:', g)
r = 0
if 'byPlayer' in locals():
matchups.update({g:byPlayer})
while r != g + 1:
print (matchups[r])
# print (r)
r += 1
else:
while r != g:
print (matchups[r])
# print (r)
r += 1
#print (players)
#print (len(players))
print (gameName, 'tournament begins now!')
matchUp(players, numMatches, numPlayers)