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

Use FIDE table for elo calculation #581

Merged
merged 13 commits into from
Oct 8, 2024

Conversation

aarew12
Copy link
Contributor

@aarew12 aarew12 commented Sep 27, 2024

Close #579

core/src/main/scala/Elo.scala Outdated Show resolved Hide resolved
core/src/main/scala/Elo.scala Outdated Show resolved Hide resolved
core/src/main/scala/Elo.scala Outdated Show resolved Hide resolved
@ornicar
Copy link
Collaborator

ornicar commented Sep 28, 2024

I think both List[Range.Inclusive, BigDecimal] and Map[Range.Inclusive, BigDecimal] are suboptimal, because we're traversing it anyway, and because these ranges are superfluous.

Instead of

val conversionTableFIDE: Map[Range.Inclusive, BigDecimal] = Map(
  (0 to 3)              -> 0.50,
  (4 to 10)             -> 0.51,
  (11 to 17)            -> 0.52,

[...]

val expectedScore = conversionTableFIDE.collectFirst {
  case (range, pd) if range.contains(absRatingDiff) => pd

I would prefer to see

val conversionTableFIDE: List[Int, BigDecimal] = List(
  3              -> 0.50,
  10             -> 0.51,
  17             -> 0.52,

[...]

val expectedScore = conversionTableFIDE.collectFirst {
  case (upperBound, pd) if upperBound >= absRatingDiff => pd

@lenguyenthanh
Copy link
Member

lenguyenthanh commented Sep 28, 2024

I would prefer to see

val conversionTableFIDE: List[Int, BigDecimal] = List(
  3              -> 0.50,
  10             -> 0.51,
  17             -> 0.52,

[...]

val expectedScore = conversionTableFIDE.collectFirst {
  case (upperBound, pd) if upperBound >= absRatingDiff => pd

I was thinking of a Map with multiple keys point to the same value:

val conversionTableFIDE: Map[Int, BigDecimal] = mapOf(
0 -> 0.5,
1 -> 0.5,
2 -> 0.5,
3 -> 0.5,
...
15 -> 0.52,
16 -> 0.52,
17 -> 0.52,
....
391 -> 0.91
)

and we can do (pseudo code)

  def getExpectedScore(ratingDiff: Int): BigDecimal =
     conversionTableFIDE.getOrElse(ratingDiff, 0.92)

@lenguyenthanh
Copy link
Member

gentle ping @ornicar for reviewing

@ornicar ornicar merged commit 7daecfe into lichess-org:master Oct 8, 2024
3 checks passed
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.

use FIDE handbook's tables in ELO computations
3 participants