Elo calculations now account for player's Elo, relative to the average Elo among players

This commit is contained in:
Joseph Prezioso Jr 2016-03-31 13:57:21 -04:00
parent cbb9798c35
commit 6ccc6df6aa

View File

@ -1279,14 +1279,61 @@ public abstract class Game implements Listener
Manager.GetChat().Silence(5000, false);
}
public int CalculateEloMultiplier(int currentElo, int averageElo)
{
int eloDifference = averageElo - currentElo;
if (Math.abs(eloDifference) <= 50)
{
return 0;
}
if (eloDifference >= 200)
{
return 3;
}
if (eloDifference >= 100)
{
return 2;
}
if (eloDifference > 50)
{
return 1;
}
if (eloDifference <= -200)
{
return -3;
}
if (eloDifference <= -100)
{
return -2;
}
if (eloDifference < 50)
{
return -1;
}
return 0;
}
public void AdjustPlayerElo(List<Player> places)
{
int averageElo = 0;
for (Player player : UtilServer.getPlayers())
{
averageElo += Manager.getEloManager().getElo(player.getUniqueId(), GetName());
}
//average Elo of all players
averageElo = averageElo/places.size();
for (Player player : UtilServer.getPlayers())
{
int currentElo = Manager.getEloManager().getElo(player.getUniqueId(), GetName());
int lossMultiplier = 1;
int sizeModifier = 3;
int eloMultiplier = CalculateEloMultiplier(currentElo, averageElo);
//nobody won, add 10 points to all players
//Profitable enough see the match through to the end, but not enough for a stale-mate to be a more desirable outcome than 3rd place
if (places == null || places.isEmpty())
@ -1300,8 +1347,8 @@ public abstract class Game implements Listener
if (places.size() >= 1)
{
if (player.getUniqueId() == places.get(0).getUniqueId())
{
int newElo = currentElo + 25;
{
int newElo = currentElo + 25 + (5 * eloMultiplier);
Manager.getEloManager().saveElo(player.getUniqueId(), GetName(), newElo);
}
}
@ -1309,7 +1356,7 @@ public abstract class Game implements Listener
{
if (player.getUniqueId() == places.get(1).getUniqueId())
{
int newElo = currentElo + 20;
int newElo = currentElo + 20 + (5 * eloMultiplier);
Manager.getEloManager().saveElo(player.getUniqueId(), GetName(), newElo);
}
}
@ -1317,7 +1364,12 @@ public abstract class Game implements Listener
{
if (player.getUniqueId() == places.get(2).getUniqueId())
{
int newElo = currentElo + 15;
if (eloMultiplier < -2)
{
eloMultiplier = -2;
}
int newElo = currentElo + 15 + (5 * eloMultiplier);
Manager.getEloManager().saveElo(player.getUniqueId(), GetName(), newElo);
}
@ -1326,7 +1378,12 @@ public abstract class Game implements Listener
{
if (player.getUniqueId() == places.get(5).getUniqueId())
{
int newElo = currentElo - 5;
if(eloMultiplier > 1)
{
eloMultiplier = 0;
}
int newElo = currentElo - 5 + (5 * eloMultiplier);
Manager.getEloManager().saveElo(player.getUniqueId(), GetName(), newElo);
}
}
@ -1334,7 +1391,12 @@ public abstract class Game implements Listener
{
if (player.getUniqueId() == places.get(6).getUniqueId())
{
int newElo = currentElo - 10;
if(eloMultiplier > 2)
{
eloMultiplier = 2;
}
int newElo = currentElo - 10 + (5 * eloMultiplier);
Manager.getEloManager().saveElo(player.getUniqueId(), GetName(), newElo);
}
}
@ -1345,7 +1407,12 @@ public abstract class Game implements Listener
{
if (player.getUniqueId() == places.get(places.size() - sizeModifier).getUniqueId())
{
int newElo = currentElo - (5 * lossMultiplier);
if(eloMultiplier > lossMultiplier)
{
eloMultiplier = lossMultiplier;
}
int newElo = currentElo - (5 * lossMultiplier) + (5 * eloMultiplier);
Manager.getEloManager().saveElo(player.getUniqueId(), GetName(), newElo);
if(sizeModifier >= 1)