Skip to content

Commit

Permalink
refine visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Nov 20, 2024
1 parent 44c4b76 commit 1216db0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions rating/src/main/scala/glicko/impl/Rating.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,41 @@ final private[glicko] class Rating(
import RatingCalculator.*

// the following variables are used to hold values temporarily whilst running calculations
private[glicko] var workingRating: Double = scala.compiletime.uninitialized
private[glicko] var workingRatingDeviation: Double = scala.compiletime.uninitialized
private[glicko] var workingVolatility: Double = scala.compiletime.uninitialized
private[impl] var workingRating: Double = scala.compiletime.uninitialized
private[impl] var workingRatingDeviation: Double = scala.compiletime.uninitialized
private[impl] var workingVolatility: Double = scala.compiletime.uninitialized

/** Return the average skill value of the player scaled down to the scale used by the algorithm's internal
* workings.
*/
def getGlicko2Rating: Double = convertRatingToGlicko2Scale(this.rating)
private[impl] def getGlicko2Rating: Double = convertRatingToGlicko2Scale(this.rating)

/** Set the average skill value, taking in a value in Glicko2 scale.
*/
def setGlicko2Rating(r: Double) =
private[impl] def setGlicko2Rating(r: Double) =
rating = convertRatingToOriginalGlickoScale(r)

/** Return the rating deviation of the player scaled down to the scale used by the algorithm's internal
* workings.
*/
def getGlicko2RatingDeviation: Double = convertRatingDeviationToGlicko2Scale(ratingDeviation)
private[impl] def getGlicko2RatingDeviation: Double = convertRatingDeviationToGlicko2Scale(ratingDeviation)

/** Set the rating deviation, taking in a value in Glicko2 scale.
*/
def setGlicko2RatingDeviation(rd: Double) =
private[impl] def setGlicko2RatingDeviation(rd: Double) =
ratingDeviation = convertRatingDeviationToOriginalGlickoScale(rd)

/** Used by the calculation engine, to move interim calculations into their "proper" places.
*/
def finaliseRating() =
private[impl] def finaliseRating() =
setGlicko2Rating(workingRating)
setGlicko2RatingDeviation(workingRatingDeviation)
volatility = workingVolatility
workingRatingDeviation = 0d
workingRating = 0d
workingVolatility = 0d

override def toString = f"Rating($rating%1.2f, $ratingDeviation%1.2f, $volatility%1.2f, $numberOfResults)"

def incrementNumberOfResults(increment: Int) =
private[impl] def incrementNumberOfResults(increment: Int) =
numberOfResults = numberOfResults + increment

override def toString = f"Rating($rating%1.2f, $ratingDeviation%1.2f, $volatility%1.2f, $numberOfResults)"
2 changes: 1 addition & 1 deletion rating/src/main/scala/glicko/impl/RatingCalculator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ final private[glicko] class RatingCalculator(
* @param results
* @param elapsedRatingPeriods
*/
def calculateNewRating(player: Rating, results: List[Result], elapsedRatingPeriods: Double): Unit =
private def calculateNewRating(player: Rating, results: List[Result], elapsedRatingPeriods: Double): Unit =
val phi = player.getGlicko2RatingDeviation
val sigma = player.volatility
val a = Math.log(Math.pow(sigma, 2))
Expand Down

0 comments on commit 1216db0

Please sign in to comment.