Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve season uncertainty reset by considering players who have not played for a while #539

Conversation

jauggy
Copy link
Member

@jauggy jauggy commented Dec 8, 2024

For the past uncertainty reset, everyone's uncertainty was set to
max(5, current_uncertainty)

This PR will make the uncertainty reset more dynamic, by giving larger reset for players who have not played in a while.

It will reset ratings to max(target_uncertainty, current_uncertainty)
where target_uncertainty is:

  • 5 for players who have played within one month
  • 8.333 or default uncertainty for players who have not played for a year or more
  • Something in between these two values for players who have not played for more than one month and less than one year.

To calculate the in between value, we use linear interpolation using the formula: https://www.cuemath.com/linear-interpolation-formula/

We can see the values would be something like this:

    one_month = 365 / 12

    result = SeasonalUncertaintyResetTask.calculate_target_uncertainty(one_month)
    assert result == 5

    result = SeasonalUncertaintyResetTask.calculate_target_uncertainty(one_month * 2)
    assert result == 5.303030303030303

    result = SeasonalUncertaintyResetTask.calculate_target_uncertainty(one_month * 3)
    assert result == 5.6060606060606063

    result = SeasonalUncertaintyResetTask.calculate_target_uncertainty(one_month * 6)
    assert result == 6.515151515151516

    result = SeasonalUncertaintyResetTask.calculate_target_uncertainty(one_month * 9)
    assert result == 7.424242424242426

    result = SeasonalUncertaintyResetTask.calculate_target_uncertainty(one_month * 11)
    assert result == 8.030303030303031

    result = SeasonalUncertaintyResetTask.calculate_target_uncertainty(365)
    assert result == 8.333333333333334

Testing

  1. Open up the database
  2. View teiserver_account_ratings table and check the last_updated column
  3. Run iex -S mix phx.server
  4. Run Teiserver.Battle.SeasonalUncertaintyResetTask.perform()
  5. This should update the uncertainties and also the last_updated column from step 2.

@jauggy jauggy force-pushed the jauggy/uncertainty-reset-improvements branch 3 times, most recently from 75a8729 to 47e9fc5 Compare December 8, 2024 05:21
Improve season uncertainty reset by taking into account players who have not played in a long time
@jauggy jauggy force-pushed the jauggy/uncertainty-reset-improvements branch from 47e9fc5 to 1960a99 Compare December 8, 2024 05:38
@jauggy jauggy marked this pull request as ready for review December 8, 2024 12:14
@L-e-x-o-n
Copy link
Collaborator

Nice improvements.
What do you think about min_uncertainity as a parameter passed to the task, in case there is a time in the future where a smaller (or larger) uncertainty reset might be wanted?

@jauggy
Copy link
Member Author

jauggy commented Dec 8, 2024

OK Lex I will make a 5 a variable that gets passed in. Marking PR as draft until I add it in.

@jauggy jauggy marked this pull request as draft December 8, 2024 19:03
@jauggy
Copy link
Member Author

jauggy commented Dec 9, 2024

Closing in favour of #540
Trying to do this in sql

@jauggy jauggy closed this Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants