Skip to content

Commit

Permalink
Merge pull request #643 from aiarena/chore/make-starting-elo-more-int…
Browse files Browse the repository at this point in the history
…uitive

Make starting_elo more intuitive by making it equal to resultan…
  • Loading branch information
lladdy authored Nov 1, 2023
2 parents 714e4e7 + 0bf94d4 commit c3053a9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
8 changes: 4 additions & 4 deletions aiarena/api/arenaclient/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,19 +339,19 @@ def create(self, request, *args, **kwargs):
result.match.round.update_if_completed()

# Update and record ELO figures
p1_initial_elo, p2_initial_elo = result.get_initial_elos
participant1.starting_elo, participant2.starting_elo = result.get_initial_elos
result.adjust_elo()

initial_elo_sum = p1_initial_elo + p2_initial_elo
initial_elo_sum = participant1.starting_elo + participant2.starting_elo

# Calculate the change in ELO
# the bot elos have changed so refresh them
# todo: instead of having to refresh, return data from adjust_elo and apply it here
sp1, sp2 = result.get_competition_participants
participant1.resultant_elo = sp1.elo
participant2.resultant_elo = sp2.elo
participant1.elo_change = participant1.resultant_elo - p1_initial_elo
participant2.elo_change = participant2.resultant_elo - p2_initial_elo
participant1.elo_change = participant1.resultant_elo - participant1.starting_elo
participant2.elo_change = participant2.resultant_elo - participant2.starting_elo
participant1.save()
participant2.save()

Expand Down
6 changes: 0 additions & 6 deletions aiarena/core/api/matches.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,6 @@ def start_match(match: Match, arenaclient: ArenaClient) -> bool:
# f" because one of the participants was not available.")
return False

if match.round: # if this is a ladder match, record the starting elo
for p in participations:
p.starting_elo = p.bot.competition_participations.only('elo', 'bot_id') \
.get(competition=match.round.competition).elo
p.save()

now = timezone.now()
match.started = now
match.first_started = now
Expand Down

0 comments on commit c3053a9

Please sign in to comment.