Search in sources :

Example 1 with Rating

use of jskills.Rating in project ACManager by kun368.

the class RatingServiceTest method generateRating.

@Test
public void generateRating() throws Exception {
    Contest contest = trainingService.getContest(135);
    List<Contest> contestList = new ArrayList<>();
    contestList.add(contest);
    List<RatingRecord> list = ratingService.generateRating(contestList, RatingRecord.Scope.Global, 1, RatingRecord.Type.Personal, 1.0);
    System.out.println(list);
    Collections.sort(list, (o1, o2) -> {
        Rating rating1 = new Rating(o1.getMean(), o1.getStandardDeviation());
        Rating rating2 = new Rating(o2.getMean(), o2.getStandardDeviation());
        return Double.compare(rating2.getConservativeRating(), rating1.getConservativeRating());
    });
    for (RatingRecord record : list) {
        Rating rating = new Rating(record.getMean(), record.getStandardDeviation());
        System.out.println(record.getIdentifier() + ":    " + rating.getMean() + "\t " + rating.getStandardDeviation() + "\t " + rating.getConservativeRating());
    }
}
Also used : Rating(jskills.Rating) ArrayList(java.util.ArrayList) Contest(com.zzkun.model.Contest) RatingRecord(com.zzkun.model.RatingRecord) Test(org.junit.Test)

Example 2 with Rating

use of jskills.Rating in project ACManager by kun368.

the class PlayerPriorValuesToSkillsLayer method buildLayer.

@Override
public void buildLayer() {
    for (ITeam currentTeam : teams) {
        List<KeyedVariable<IPlayer, GaussianDistribution>> currentTeamSkills = new ArrayList<>();
        for (Entry<IPlayer, Rating> currentTeamPlayer : currentTeam.entrySet()) {
            KeyedVariable<IPlayer, GaussianDistribution> playerSkill = createSkillOutputVariable(currentTeamPlayer.getKey());
            AddLayerFactor(createPriorFactor(currentTeamPlayer.getKey(), currentTeamPlayer.getValue(), playerSkill));
            currentTeamSkills.add(playerSkill);
        }
        addOutputVariableGroup(currentTeamSkills);
    }
}
Also used : IPlayer(jskills.IPlayer) GaussianDistribution(jskills.numerics.GaussianDistribution) Rating(jskills.Rating) ArrayList(java.util.ArrayList) ITeam(jskills.ITeam)

Example 3 with Rating

use of jskills.Rating in project ACManager by kun368.

the class TrueSkillFactorGraph method getUpdatedRatings.

public Map<IPlayer, Rating> getUpdatedRatings() {
    Map<IPlayer, Rating> result = new HashMap<>();
    for (List<KeyedVariable<IPlayer, GaussianDistribution>> currentTeam : priorLayer.getOutputVariablesGroups()) {
        for (KeyedVariable<IPlayer, GaussianDistribution> currentPlayer : currentTeam) {
            final Rating rating = new Rating(currentPlayer.getValue().getMean(), currentPlayer.getValue().getStandardDeviation());
            result.put(currentPlayer.getKey(), rating);
        }
    }
    return result;
}
Also used : IPlayer(jskills.IPlayer) GaussianDistribution(jskills.numerics.GaussianDistribution) Rating(jskills.Rating)

Example 4 with Rating

use of jskills.Rating in project VoxelGamesLibv2 by VoxelGamesLib.

the class EloHandler method handleGameEnd.

/**
 * Handles the elo calculation for generic games
 *
 * @param game  the game that ended
 * @param users the users which played this game, in order, first = winner
 */
public void handleGameEnd(@Nonnull Game game, @Nonnull User... users) {
    List<ITeam> teams = new ArrayList<>();
    for (User user : users) {
        teams.add(new jskills.Team(user, user.getRating(game.getGameMode())));
    }
    Map<IPlayer, Rating> newRatings = calculator.calculateNewRatings(game.getGameMode(), teams, IntStream.of(users.length).toArray());
    update(game, newRatings);
}
Also used : IPlayer(jskills.IPlayer) User(com.voxelgameslib.voxelgameslib.user.User) Rating(jskills.Rating) ArrayList(java.util.ArrayList) ITeam(jskills.ITeam)

Aggregations

Rating (jskills.Rating)4 ArrayList (java.util.ArrayList)3 IPlayer (jskills.IPlayer)3 ITeam (jskills.ITeam)2 GaussianDistribution (jskills.numerics.GaussianDistribution)2 User (com.voxelgameslib.voxelgameslib.user.User)1 Contest (com.zzkun.model.Contest)1 RatingRecord (com.zzkun.model.RatingRecord)1 Test (org.junit.Test)1