19
19
*/
20
20
public class Rating {
21
21
22
+ private final double advantage ;
22
23
private double rating ;
23
24
private double ratingDeviation ;
24
25
private double volatility ;
@@ -31,17 +32,35 @@ public class Rating {
31
32
private double workingVolatility ;
32
33
33
34
public Rating (double initRating , double initRatingDeviation , double initVolatility , int nbResults ) {
34
- this (initRating , initRatingDeviation , initVolatility , nbResults , null );
35
+ this (0.0d , initRating , initRatingDeviation , initVolatility , nbResults , null );
35
36
}
36
37
37
38
public Rating (double initRating , double initRatingDeviation , double initVolatility , int nbResults , DateTime lastRatingPeriodEndDate ) {
39
+ this (0.0d , initRating , initRatingDeviation , initVolatility , nbResults , lastRatingPeriodEndDate );
40
+ }
41
+
42
+ public Rating (double advantage , double initRating , double initRatingDeviation , double initVolatility , int nbResults , DateTime lastRatingPeriodEndDate ) {
43
+ this .advantage = advantage ;
38
44
this .rating = initRating ;
39
45
this .ratingDeviation = initRatingDeviation ;
40
46
this .volatility = initVolatility ;
41
47
this .numberOfResults = nbResults ;
42
48
this .lastRatingPeriodEndDate = lastRatingPeriodEndDate ;
43
49
}
44
50
51
+ public Rating withAdvantage (double advantage ) {
52
+ return new Rating (advantage , rating , ratingDeviation , volatility , numberOfResults , lastRatingPeriodEndDate );
53
+ }
54
+
55
+ /**
56
+ * Return the skill advantage (first-player handicap) value.
57
+ *
58
+ * @return double
59
+ */
60
+ public double getAdvantage () {
61
+ return this .advantage ;
62
+ }
63
+
45
64
/**
46
65
* Return the average skill value of the player.
47
66
*
@@ -55,6 +74,16 @@ public void setRating(double rating) {
55
74
this .rating = rating ;
56
75
}
57
76
77
+ /**
78
+ * Return the average skill value of the player scaled down
79
+ * to the scale used by the algorithm's internal workings.
80
+ *
81
+ * @return double
82
+ */
83
+ public double getGlicko2RatingWithAdvantage () {
84
+ return RatingCalculator .convertRatingToGlicko2Scale (this .rating + advantage );
85
+ }
86
+
58
87
/**
59
88
* Return the average skill value of the player scaled down
60
89
* to the scale used by the algorithm's internal workings.
@@ -70,7 +99,7 @@ public double getGlicko2Rating() {
70
99
*
71
100
* @param double
72
101
*/
73
- public void setGlicko2Rating (double rating ) {
102
+ private void setGlicko2Rating (double rating ) {
74
103
this .rating = RatingCalculator .convertRatingToOriginalGlickoScale (rating );
75
104
}
76
105
0 commit comments