Last active
August 29, 2015 14:12
-
-
Save stuntguy3000/0365c050671ff7f6ff30 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package be.multicu.core.util; | |
/** | |
* | |
* @author Codepanda | |
*/ | |
public class Rating { | |
private static int MAX_POINTS = 20; | |
private static int MIN_POINTS = 4; | |
/** | |
* This method is used to determine the points for two players. This system | |
* is based on the ELO system and has a min and max amount of points. | |
* @param winner The current points of the winner | |
* @param loser The current points of the loser | |
* @return int This returns the point difference to be added/removed from players | |
*/ | |
public static int getELOPoints(int winner, int loser) { | |
float elo = (float) (1f / (1f + Math.pow(10f, ((looser - winner) / 800f)))); | |
int points = (int) Math.round(20 * (1f - elo)); | |
if (points < MIN_POINTS) { | |
points = MIN_POINTS; | |
} else if (points > MAX_POINTS) { | |
points = MAX_POINTS; | |
} | |
return points; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment