https://github.com/gitrasheed/elo_rating
Python Elo Ranking
https://github.com/gitrasheed/elo_rating
Last synced: 5 days ago
JSON representation
Python Elo Ranking
- Host: GitHub
- URL: https://github.com/gitrasheed/elo_rating
- Owner: gitRasheed
- License: mit
- Created: 2023-07-22T19:53:50.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-23T12:34:00.000Z (almost 3 years ago)
- Last Synced: 2023-07-23T13:32:51.671Z (almost 3 years ago)
- Language: Python
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Elo
Python Elo Ranking System
API:
calculate_new_elos
Calculates the new Elo ratings for two players after a match. This will be the method
```
new_elo1, new_elo2 = calculate_new_elos(1500, 1500, 1)
```
Player
A player in an Elo system.
__init__(self, name: str, elo: int)
Creates a new player with a given name and Elo rating.
```
player = Player("Alice", 1500)
```
record_match(self, opponent_name: str, outcome: str, new_elo: int)
Records a match for the player against an opponent, specifying the outcome and updating the Elo rating.
```
player.record_match("Bob", "Alice", 1520)
```
Elo
The Elo rating system.
__init__(self, k_factor: int = 32)
Creates a new Elo system with a specified K-factor.
add_player(self, name: str, elo: int = 1500)
Adds a new player to the Elo system with a specified name and initial Elo rating.
```
elo.add_player("Alice", 1500)
```
record_match(self, name1: str, name2: str, outcome: str)
Records a match between two players in the Elo system and updates their Elo ratings.
```
elo.record_match("Alice", "Bob", "Alice")
```