Skip to content

Commit 574a2e7

Browse files
authored
Fix RD "decay" in Glicko-1 rating calculations (#30)
1 parent 8c32fab commit 574a2e7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/ladder.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,11 @@ export class GlickoPlayer {
387387

388388
// Follow along the steps using: http://www.glicko.net/glicko/glicko.pdf
389389

390+
let RD = Math.sqrt((this.rd * this.rd) + (this.c * this.c));
391+
if (RD > this.RDmax) {
392+
RD = this.RDmax;
393+
}
390394
if (m.length === 0) {
391-
const RD = Math.sqrt((this.rd * this.rd) + (this.c * this.c));
392395
return { R: this.rating, RD };
393396
}
394397

@@ -405,7 +408,7 @@ export class GlickoPlayer {
405408

406409
d2 = 1.0 / this.q / this.q / d2;
407410

408-
let RD = 1.0 / Math.sqrt(1.0 / (this.rd * this.rd) + 1.0 / d2);
411+
RD = 1.0 / Math.sqrt(1.0 / (RD * RD) + 1.0 / d2);
409412
const R = this.rating + this.q * (RD * RD) * A;
410413

411414
if (RD > this.RDmax) {

0 commit comments

Comments
 (0)