Skip to content

Commit

Permalink
rough code
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinzhu00 committed Oct 12, 2019
1 parent 218df86 commit 58d7f33
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 39 deletions.
34 changes: 16 additions & 18 deletions matches.csv
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
Blue 1 ID, Blue 1 Name, Blue 2 ID, Blue 2 Name, Gold 1 ID, Gold 1 Name, Gold 2 ID, Gold 2 Name
37,CCPA,15,Pinole Valley,10,Skyline,1,Albany
31,Arroyo,26,OSA,8,Bishop O'Dowd,29,Realm
35,Hayward One,40,Salesian,17,ACLC,41,ARISE
36,Miramonte,3,De Anza,42,John Henry,20,Encinal
12,El Cerrito,9,Hercules,4,LPS Richmond,6,Middle College
43,Hayward Two,36,Miramonte,20,Encinal,40,Salesian
41,ARISE,35,Hayward One,8,Bishop O'Dowd,1,Albany
12,El Cerrito,40,Salesian,43,Hayward Two,10,Skyline
3,De Anza,20,Encinal,29,Realm,15,Pinole Valley
6,Middle College,42,John Henry,37,CCPA,26,OSA
36,Miramonte,9,Hercules,4,LPS Richmond,17,ACLC
31,Arroyo,29,Realm,35,Hayward One,8,Bishop O'Dowd
41,ARISE,3,De Anza,26,OSA,17,ACLC
40,Salesian,35,Hayward One,1,Albany,43,Hayward Two
29,Realm,15,Pinole Valley,20,Encinal,8,Bishop O'Dowd
36,Miramonte,4,LPS Richmond,12,El Cerrito,9,Hercules
37,CCPA,42,John Henry,6,Middle College,31,Arroyo
10,Skyline,35,Hayward One,8,Bishop O'Dowd,1,Albany
36,Miramonte,6,Middle College,10,Skyline,4,LPS Richmond
17,ACLC,31,Arroyo,8,Bishop O'Dowd,43,Hayward Two
3,De Anza,20,Encinal,26,OSA,9,Hercules
29,Realm,37,CCPA,12,El Cerrito,40,Salesian
42,John Henry,35,Hayward One,15,Pinole Valley,41,ARISE
1,Albany,8,Bishop O'Dowd,17,ACLC,9,Hercules
31,Arroyo,43,Hayward Two,12,El Cerrito,4,LPS Richmond
42,John Henry,26,OSA,35,Hayward One,6,Middle College
20,Encinal,36,Miramonte,3,De Anza,41,ARISE
15,Pinole Valley,37,CCPA,29,Realm,40,Salesian
1,Albany,10,Skyline,4,LPS Richmond,35,Hayward One
42,John Henry,17,ACLC,6,Middle College,9,Hercules
43,Hayward Two,12,El Cerrito,3,De Anza,40,Salesian
37,CCPA,41,ARISE,15,Pinole Valley,29,Realm
10,Skyline,8,Bishop O'Dowd,36,Miramonte,31,Arroyo
1,Albany,20,Encinal,26,OSA,-1,Spooky Team
52 changes: 32 additions & 20 deletions newscheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
from random import randint
import os.path
from itertools import permutations
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-input')
args = parser.parse_args()
print(args)


class Match:
def __init__(self, b1, b2, g1, g2):
Expand All @@ -16,16 +22,18 @@ def __init__(self, id, name):
self.name = name
self.canPlay = 0
self.playedWith = []
self.playedAgainst = []

schools = []

print("test")
def process(line):
values = line.rstrip().split(",")
print(values)
schools.append(Team(values[0], values[1]))

input = sys.stdin.readline().rstrip().split(" ")
csvFile = input[0]
roundsPerTeam = int(input[1])
#input = sys.stdin.readline().rstrip().split(" ")
csvFile = args.input


with open(csvFile) as f:
for line in f:
Expand All @@ -36,6 +44,7 @@ def process(line):
totalRounds = len(schools)//4*3
for i in range(totalRounds):
matchedTeams = []
print(i)
if len(teamsLeft) >= 4:
j = 0
while j < 4:
Expand All @@ -55,23 +64,26 @@ def process(line):
matchedTeams.append(team)
teamsLeft.remove(team)
k += 1
perm = list(permutations(range(4)))
for p in perm:
if matchedTeams[p[0]] not in matchedTeams[p[1]].playedWith and matchedTeams[p[2]] not in matchedTeams[p[3]].playedWith:
matches.append(Match(matchedTeams[p[0]],matchedTeams[p[1]],matchedTeams[p[2]],matchedTeams[p[3]]))
matchedTeams[p[0]].playedWith.append(matchedTeams[p[1]])
matchedTeams[p[1]].playedWith.append(matchedTeams[p[0]])
matchedTeams[p[2]].playedWith.append(matchedTeams[p[3]])
matchedTeams[p[3]].playedWith.append(matchedTeams[p[2]])
for t in [matchedTeams[p[r]] for r in range(4)]:
t.canPlay = gap*-1 -1
break
for s in schools:
s.canPlay += 1
perm = list(permutations(range(4)))
for p in perm:
if matchedTeams[p[0]] not in matchedTeams[p[1]].playedWith and matchedTeams[p[2]] not in matchedTeams[p[3]].playedWith:
print("making match")
matches.append(Match(matchedTeams[p[0]],matchedTeams[p[1]],matchedTeams[p[2]],matchedTeams[p[3]]))
matchedTeams[p[0]].playedWith.append(matchedTeams[p[1]])
matchedTeams[p[1]].playedWith.append(matchedTeams[p[0]])
matchedTeams[p[2]].playedWith.append(matchedTeams[p[3]])
matchedTeams[p[3]].playedWith.append(matchedTeams[p[2]])
for t in [matchedTeams[p[r]] for r in range(4)]:
t.canPlay = gap*-1 -1
break
for s in schools:
s.canPlay += 1
print(len(matches))
if teamsLeft:
ghosts = 4 - len(teamsLeft)
for g in range(ghosts):
teamsLeft.append(Team(-g-1,"Spooky Team"))
teamsLeft.append(Team("-1","Spooky Team"))
matchedTeams = teamsLeft
perm = list(permutations(range(4)))
for p in perm:
if matchedTeams[p[0]] not in matchedTeams[p[1]].playedWith and matchedTeams[p[2]] not in matchedTeams[p[3]].playedWith:
Expand All @@ -86,8 +98,8 @@ def process(line):
if writeHeader:
f.write("Blue 1 ID, Blue 1 Name, Blue 2 ID, Blue 2 Name, Gold 1 ID, Gold 1 Name, Gold 2 ID, Gold 2 Name\n")
for m in matches:
print(m.g2.name)
f.write(m.b1.id + "," + m.b1.name +
"," + m.b2.id + "," + m.b2.name +
"," + m.g1.id + "," + m.g1.name +
"," + m.g2.id + "," +
m.g2.name + "\n")
"," + m.g2.id + "," + m.g2.name + "\n")
1 change: 0 additions & 1 deletion schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import os.path
parser = argparse.ArgumentParser()
parser.add_argument('-input')
parser.add_argument('-n')
args = parser.parse_args()
print(args)

Expand Down

0 comments on commit 58d7f33

Please sign in to comment.