From 7e40534e23e244de1f4ef83aa79313e71999d29c Mon Sep 17 00:00:00 2001 From: Lionel Panhaleux Date: Mon, 16 Sep 2024 09:28:45 +0200 Subject: [PATCH] Fix minor seating issue --- CHANGELOG.rst | 2 +- krcg/seating.py | 2 +- tests/test_seating.py | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 15585c7..49e8763 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,7 +4,7 @@ Changelog 4.1 (unreleased) ---------------- -- Nothing changed yet. +- Fix a niche case seating score error (players playing twice in rare situations) 4.0 (2024-09-15) diff --git a/krcg/seating.py b/krcg/seating.py index f36222b..bfbf3b1 100644 --- a/krcg/seating.py +++ b/krcg/seating.py @@ -393,7 +393,7 @@ def fast_total(measure: Measure, rounds_count: int) -> float: # Transfers difference numpy.sum((transfers - numpy.mean(transfers)) ** 2) / transfers.size, # same position groups for an opponent twice - numpy.count_nonzero(opponents_twice[6:] > 1) // 2 if collisions else 0, + numpy.count_nonzero(opponents_twice[:, 6:] > 1) // 2 if collisions else 0, ] # builtins.sum is expensive return ( diff --git a/tests/test_seating.py b/tests/test_seating.py index ec43a56..8a2d0f2 100644 --- a/tests/test_seating.py +++ b/tests/test_seating.py @@ -267,6 +267,12 @@ def test_score(): ] assert score.rules == [0, 10, 0, 10, 0, 0, 3, 0.9092121131323905, 10] assert score.total == 10010003100.921211 + # fast total is slightly lower because it does not sqrt the stdevs. + # it has no impact in the "ordering" of solutions though, so it's fine + pm = seating.player_mapping(rounds) + measure = sum(seating.measure(pm, r) for r in rounds) + fast_total = seating.Score.fast_total(measure, len(rounds)) + assert fast_total == 10010003092.666666 def test_optimise():