Skip to content

Commit

Permalink
Fix minor seating issue
Browse files Browse the repository at this point in the history
  • Loading branch information
lionel-panhaleux committed Sep 16, 2024
1 parent b0e4c11 commit 7e40534
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion krcg/seating.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
6 changes: 6 additions & 0 deletions tests/test_seating.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 7e40534

Please sign in to comment.