aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.py111
-rw-r--r--src/ladder.py5
2 files changed, 112 insertions, 4 deletions
diff --git a/main.py b/main.py
index 4e066b8..ed15689 100644
--- a/main.py
+++ b/main.py
@@ -5,8 +5,9 @@ from src.ladder import Ladder
from src.player import Player
from src.strategy import SimpleEloChangeStrategy
-ladder = Ladder()
-ladder.strategy = SimpleEloChangeStrategy()
+ladder = Ladder(
+ strategy=SimpleEloChangeStrategy(),
+)
games: list[Game] = [
@@ -187,12 +188,116 @@ games: list[Game] = [
Player.Baptiste: 43,
},
),
+ Game(
+ datetime.fromisoformat("2024-05-08 12:00"), # ?
+ {
+ Player.Thomas: 54,
+ Player.Emma: 45,
+ Player.Pierre: 67,
+ },
+ ),
+ Game(
+ datetime.fromisoformat("2024-05-08 13:24"),
+ {
+ Player.Thomas: 47,
+ Player.Emma: 46,
+ Player.Pierre: 56,
+ },
+ ),
+ Game(
+ datetime.fromisoformat("2024-05-08 14:24"), # ?
+ {
+ Player.Thomas: 58,
+ Player.Emma: 68,
+ Player.Pierre: 69,
+ },
+ ),
+ Game(
+ datetime.fromisoformat("2024-05-10 14:21"),
+ {
+ Player.Emma: 60,
+ Player.Baptiste: 45,
+ Player.Thomas: 59,
+ Player.Kim: 51,
+ Player.Theo: 47,
+ Player.Felix: 41,
+ },
+ ),
+ Game(
+ datetime.fromisoformat("2024-05-10 15:00"),
+ {
+ Player.Emma: 51,
+ Player.Baptiste: 49,
+ Player.Thomas: 38,
+ Player.Felix: 61,
+ },
+ ),
+ Game(
+ datetime.fromisoformat("2024-05-11 14:00"),
+ {
+ Player.Felix: 57,
+ Player.Kim: 38,
+ Player.Thomas: 62,
+ Player.Frost: 58,
+ Player.Pierre: 51,
+ Player.Martin: 58,
+ Player.Emma: 46,
+ },
+ ),
+ # Game(
+ # datetime.fromisoformat("2024-05-24 12:00"), # ?
+ # {
+ # Player.Martin: 53,
+ # Player.Emma: 40,
+ # Player.Marius: 39,
+ # Player.Heloise: 44,
+ # },
+ # ),
+ Game(
+ datetime.fromisoformat("2025-01-01 13:27"),
+ {
+ Player.Clementine: 55,
+ Player.Thomas: 73,
+ Player.Baptiste: 55,
+ Player.Felix: 50,
+ Player.Emma: 58,
+ },
+ ),
+ Game(
+ datetime.fromisoformat("2025-01-01 13:58"),
+ {
+ Player.Clementine: 60,
+ Player.Thomas: 56,
+ Player.Theo: 60,
+ Player.Felix: 62,
+ Player.Emma: 47,
+ },
+ ),
+ Game(
+ datetime.fromisoformat("2025-01-03 11:00"),
+ {
+ Player.Tanguy: 90,
+ Player.Clementine: 70,
+ Player.Martin: 72,
+ Player.Emma: 39,
+ },
+ ),
+ Game(
+ datetime.fromisoformat("2025-01-03 11:45"),
+ {
+ Player.Tanguy: 62,
+ Player.Clementine: 86,
+ Player.Theo: 54,
+ Player.Martin: 94,
+ Player.Emma: 60,
+ },
+ ),
]
for game in games:
print(game)
print("=" * 30)
- players_elo_updates = ladder.proccess_game(game)
+ players_elo_updates = ladder.process_game(game)
for player, elo_update in players_elo_updates.items():
print(
diff --git a/src/ladder.py b/src/ladder.py
index 4ea87fa..ffbbf57 100644
--- a/src/ladder.py
+++ b/src/ladder.py
@@ -35,12 +35,15 @@ class Ladder:
player: PlayerStatus.create(player) for player in Player
}
+ def __init__(self,*, strategy: GameEloChangeStrategy) -> None:
+ self.strategy = strategy
+
def current_elo(self) -> dict[Player, int]:
return {
player: player_status.elo for player, player_status in self.players.items()
}
- def proccess_game(self, game: Game) -> dict[Player, float]:
+ def process_game(self, game: Game) -> dict[Player, float]:
players_elo_updates = self.strategy.proccess_game(game, self.current_elo())
for player, elo_update in players_elo_updates.items():