Ranking Players using Elo algorithm.
Given two files:
-
Players file: Each line has an ID number and a name for that player. File name and location is defined in
application.properties with the propertyplayers.filename
. Default value is ./players.txt -
Matches file: Each line contains the ID of the two players of a match and the first one is the winner of that match. File name and location is defined in
application.properties with the propertymatches.filename
Default value is ./matches.txt
Required:
- Java 11
- Maven
mvn clean install
Example:
mvn spring-boot:run -Dspring-boot.run.arguments="SHOW_DETAILS 13"
Use -Dspring-boot.run.arguments
to send different options.
After running mvn clean install
jar application elo-0.0.1-SNAPSHOT.jar
could be found on ./target directory.
Example:
java -jar target/elo-0.0.1-SNAPSHOT.jar SHOW_DETAILS 13
Where SHOW_DETAILS
and 13
are application options.
LIST_PLAYERS
: Shows a list of players and their ranking, number of wins and losses. By default, the list is sorted byRANKING
. However other sort options could beID
,NAME
,RANKING
,WINS
,LOSSES
. it is possible as well to change the sorting direction using the optionsASC
,DES
. By default, the list is sorted by usingASC
.
Example:
java -jar target/elo-0.0.1-SNAPSHOT.jar LIST_PLAYERS WINS DES
SHOW_DETAILS
: Shows the player details like ranking, number of wins, losses. Additionally, it shows whom the player won or lost and the number of times. For this option is mandatory a second parameter with theplayerId
.
Example:
java -jar target/elo-0.0.1-SNAPSHOT.jar SHOW_DETAILS 13
GENERATE_MATCH
: Shows a list of Player ID pairs with suggested matches. Matches are arranged based on player ranking. Matches with similar player rankings will be fun and challenging for the players. A match is generated per player in the list. As the player list might not be even in terms of the number of players, a player might need to play twice.
Location of the source files players.filename
and matches.filename
can be changed when running the application.
Example:
java -jar target/elo-0.0.1-SNAPSHOT.jar SHOW_DETAILS 13 --players.filename=./new_players_file.txt
-
Console entry point is io.fysus.elo.CommandRunner class.
-
Based on the chosen option one of the io.fysus.elo.controller.Controller is executed.
-
Controllers classes rely on Services implementations in the package io.fysus.elo.service to obtain the information and that information is formatted and reported using one of the implementations of io.fysus.elo.formatter.OutputFormatter
-
Service Implementation in the package io.fysus.elo.service rely on io.fysus.elo.core.MatchAnalyzer to obtain match and player statistics.
See License
- Twitter: @fysus
- Linkedin: https://www.linkedin.com/in/fredysierra/
Copyright (c) 2020 Fredy Sierra