Implement avoidSameFamily geographic criterion

When enabled, avoid pairing players from the same club who have
the same family name (surname). Uses existing player.name field.
This commit is contained in:
Claude Brisson
2025-11-29 22:00:31 +01:00
parent 147347fa6e
commit 17697845fd
4 changed files with 17 additions and 2 deletions

View File

@@ -87,6 +87,7 @@ data class GeographicalParams(
val preferMMSDiffRatherThanSameClubsGroup: Int = 2, // Typically = 2
val preferMMSDiffRatherThanSameClub: Int = 3, // Typically = 3
val proportionMainClubThreshold: Double = 0.4, // If the biggest club has a proportion of players higher than this, the secondary criterium is not applied
val avoidSameFamily: Boolean = false, // When enabled, avoid pairing players from the same club with the same family name
) {
companion object {
val disabled = GeographicalParams(avoidSameGeo = 0.0)

View File

@@ -504,7 +504,14 @@ sealed class Solver(
// else: effectiveCommonClub = true → clubRatio stays 0 (no bonus for same club)
clubRatio = min(clubRatio, 1.0)
// TODO Same family
// Same family: when enabled and players are from the same club, check if they have the same surname
// If so, remove the bonus to avoid pairing family members (even if local club logic gave them a bonus)
if (avoidSameFamily && commonClub) {
val sameFamily = p1.name.uppercase() == p2.name.uppercase()
if (sameFamily) {
clubRatio = 0.0 // No bonus for same family within same club
}
}
// compute geoRatio
val mainPart = max(countryRatio, clubRatio)