prepare for live updates
This commit is contained in:
parent
97e16e6be2
commit
6cd253d5f0
@ -2,10 +2,6 @@ import numpy as np
|
|||||||
import json
|
import json
|
||||||
import itertools
|
import itertools
|
||||||
from pathlib import Path
|
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)
|
rgen = np.random.default_rng(seed=42)
|
||||||
|
|
||||||
@ -35,29 +31,11 @@ def load_stats():
|
|||||||
# rgen = np.random.default_rng(seed=42)
|
# rgen = np.random.default_rng(seed=42)
|
||||||
|
|
||||||
# n_prefs = 8
|
# n_prefs = 8
|
||||||
# people = {
|
# preferences = {
|
||||||
# player: rgen.choice(players, size=n_prefs, replace=False) for player in players
|
# 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():
|
def team_table_json():
|
||||||
players, preferences = load_stats()
|
players, preferences = load_stats()
|
||||||
mean, team0, team1 = apply_brute_force(players, preferences)
|
mean, team0, team1 = apply_brute_force(players, preferences)
|
||||||
@ -99,6 +77,7 @@ def apply_brute_force(players, preferences):
|
|||||||
if percentage == best_percentage[0][0] and set(team0) != set(best_score[0][1]):
|
if percentage == best_percentage[0][0] and set(team0) != set(best_score[0][1]):
|
||||||
best_percentage.append((percentage, team0, team1))
|
best_percentage.append((percentage, team0, team1))
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
for result in best_score:
|
for result in best_score:
|
||||||
print(result[0])
|
print(result[0])
|
||||||
print(result[1])
|
print(result[1])
|
||||||
|
Loading…
Reference in New Issue
Block a user