prepare for live updates

This commit is contained in:
julius 2024-11-02 09:49:49 +01:00
parent 97e16e6be2
commit 6cd253d5f0
Signed by: julius
GPG Key ID: C80A63E6A5FD7092

View File

@ -2,10 +2,6 @@ import numpy as np
import json
import itertools
from pathlib import Path
from rich.console import Console
from rich.table import Table
from rich.text import Text
from rich import box
rgen = np.random.default_rng(seed=42)
@ -35,29 +31,11 @@ def load_stats():
# rgen = np.random.default_rng(seed=42)
# n_prefs = 8
# people = {
# preferences = {
# player: rgen.choice(players, size=n_prefs, replace=False) for player in players
# }
def team_table(mean, team0, team1):
console = Console(record=True)
console.print(Text(f"mean wishes fulfilled: {score:.02f}"))
for i, team in enumerate([team0, team1]):
table = Table(title=f"Team {i}", box=box.ROUNDED, show_lines=True)
table.add_column("player", justify="right", style="cyan")
table.add_column("wishes fulfilled", justify="center", style="magenta")
table.add_column("in %", justify="center", style="green")
for p in sorted(list(team)):
prefs = people[p]
matches = sum([pref in team for pref in people[p]])
table.add_row(
p, f"{matches:d}", f"{matches/len(prefs):.2%}" if prefs else ""
)
console.print(table)
console.save_html("tables.html")
def team_table_json():
players, preferences = load_stats()
mean, team0, team1 = apply_brute_force(players, preferences)
@ -99,15 +77,16 @@ def apply_brute_force(players, preferences):
if percentage == best_percentage[0][0] and set(team0) != set(best_score[0][1]):
best_percentage.append((percentage, team0, team1))
for result in best_score:
print(result[0])
print(result[1])
print(result[2])
if __name__ == "__main__":
for result in best_score:
print(result[0])
print(result[1])
print(result[2])
for result in best_percentage:
print(result[0])
print(result[1])
print(result[2])
for result in best_percentage:
print(result[0])
print(result[1])
print(result[2])
# team_table(score, team0, team1)
return best_score[0]