Skip to content

Commit 321b8a5

Browse files
authored
Merge pull request #46 from Benezivas/develop
Release 3.0.2
2 parents a21f51d + 04072d2 commit 321b8a5

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

algobattle/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
__title__ = 'Algorithmic Battle'
2-
__version__ = '3.0.1'
2+
__version__ = '3.0.2'
33
__author__ = 'Jan Dreier, Henri Lotze'
44
__license__ = 'MIT'

algobattle/battle_wrappers/averaged.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Wrapper that iterates the instance size up to a point where the solving team is no longer able to solve an instance."""
22

3+
import itertools
34
import logging
45

56
from algobattle.battle_wrapper import BattleWrapper
@@ -43,9 +44,9 @@ def wrapper(self, match, options: dict = {}) -> None:
4344
def calculate_points(self, match_data: dict, achievable_points: int) -> dict:
4445
"""Calculate the number of achieved points, given results.
4546
46-
The valuation of an averaged battle is the number of successfully
47-
executed battles divided by the average competitive ratio of successful
48-
battles, to account for failures on execution.
47+
The valuation of an averaged battle is calculating by summing up
48+
the reciprocals of each solved fight. This sum is then divided by
49+
the total number of ratios to account for unsuccessful battles.
4950
5051
Parameters
5152
----------
@@ -68,14 +69,15 @@ def calculate_points(self, match_data: dict, achievable_points: int) -> dict:
6869
team_names = set()
6970
for pair in team_pairs:
7071
team_names = team_names.union(set((pair[0], pair[1])))
72+
team_combinations = itertools.combinations(team_names, 2)
7173

7274
if len(team_names) == 1:
7375
return {team_names.pop(): achievable_points}
7476

7577
if match_data['rounds'] <= 0:
7678
return {}
77-
points_per_iteration = round(achievable_points / match_data['rounds'], 1)
78-
for pair in team_pairs:
79+
points_per_round = round(achievable_points / match_data['rounds'], 1)
80+
for pair in team_combinations:
7981
for i in range(match_data['rounds']):
8082
points[pair[0]] = points.get(pair[0], 0)
8183
points[pair[1]] = points.get(pair[1], 0)
@@ -86,9 +88,9 @@ def calculate_points(self, match_data: dict, achievable_points: int) -> dict:
8688
valuation0 = 0
8789
valuation1 = 0
8890
if ratios0 and sum(ratios0) != 0:
89-
valuation0 = (len(ratios0) / sum(ratios0)) / len(ratios0)
91+
valuation0 = sum(1 / x if x != 0 else 0 for x in ratios0) / len(ratios0)
9092
if ratios1 and sum(ratios1) != 0:
91-
valuation1 = (len(ratios1) / sum(ratios1)) / len(ratios1)
93+
valuation1 = sum(1 / x if x != 0 else 0 for x in ratios1) / len(ratios1)
9294

9395
# Default values for proportions, assuming no team manages to solve anything
9496
points_proportion0 = 0.5
@@ -99,8 +101,8 @@ def calculate_points(self, match_data: dict, achievable_points: int) -> dict:
99101
points_proportion0 = (valuation0 / (valuation0 + valuation1))
100102
points_proportion1 = (valuation1 / (valuation0 + valuation1))
101103

102-
points[pair[0]] += round(points_per_iteration * points_proportion0, 1) / 2
103-
points[pair[1]] += round(points_per_iteration * points_proportion1, 1) / 2
104+
points[pair[0]] += round(points_per_round * points_proportion0, 1)
105+
points[pair[1]] += round(points_per_round * points_proportion1, 1)
104106

105107
return points
106108

0 commit comments

Comments
 (0)