Fix to ranking algorithm (#826)

* fixed ranking

* fix index error

Co-authored-by: Alexander Mattick <alex.mattick@fau.de>
This commit is contained in:
MattAlexMiracle
2023-01-18 21:27:16 +01:00
committed by GitHub
co-authored by Alexander Mattick
parent 9b98056001
commit 530194de08
2 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -101,7 +101,7 @@ def ranked_pairs(ranks: List[List[int]]):
# order by strength of victory (using tideman's original method, don't think it would make a difference for us) # order by strength of victory (using tideman's original method, don't think it would make a difference for us)
sorted_majorities = [] sorted_majorities = []
for i in range(len(ranks[0])): for i in range(len(ranks[0])):
for j in range(len(ranks[i])): for j in range(len(ranks[0])):
if tallies[i, j] > 0: if tallies[i, j] > 0:
sorted_majorities.append((i, j, tallies[i, j])) sorted_majorities.append((i, j, tallies[i, j]))
# we don't explicitly deal with tied majorities here # we don't explicitly deal with tied majorities here
+3 -3
View File
@@ -101,7 +101,7 @@ def ranked_pairs(ranks: List[List[int]]):
# order by strength of victory (using tideman's original method, don't think it would make a difference for us) # order by strength of victory (using tideman's original method, don't think it would make a difference for us)
sorted_majorities = [] sorted_majorities = []
for i in range(len(ranks[0])): for i in range(len(ranks[0])):
for j in range(len(ranks[i])): for j in range(len(ranks[0])):
if tallies[i, j] > 0: if tallies[i, j] > 0:
sorted_majorities.append((i, j, tallies[i, j])) sorted_majorities.append((i, j, tallies[i, j]))
# we don't explicitly deal with tied majorities here # we don't explicitly deal with tied majorities here
@@ -132,8 +132,8 @@ if __name__ == "__main__":
[("w", "x", "z", "y") for _ in range(1)] [("w", "x", "z", "y") for _ in range(1)]
+ [("w", "y", "x", "z") for _ in range(2)] + [("w", "y", "x", "z") for _ in range(2)]
# + [("x","y","z","w") for _ in range(4)] # + [("x","y","z","w") for _ in range(4)]
+ [("x", "z", "w", "y") for _ in range(5)] # + [("x", "z", "w", "y") for _ in range(5)]
+ [("y", "w", "x", "z") for _ in range(1)] # + [("y", "w", "x", "z") for _ in range(1)]
# [("y","z","w","x") for _ in range(1000)] # [("y","z","w","x") for _ in range(1000)]
) )
rp = ranked_pairs(ranks) rp = ranked_pairs(ranks)