From 70270bd528f92e8b27380d6d19c0890c8b5bd848 Mon Sep 17 00:00:00 2001 From: Claude Brisson Date: Tue, 26 Dec 2023 10:07:30 +0100 Subject: [PATCH] always choose white for the strongest player with handicap --- .../org/jeudego/pairgoth/pairing/solver/BaseSolver.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/solver/BaseSolver.kt b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/solver/BaseSolver.kt index 66832b8..3bc3462 100644 --- a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/solver/BaseSolver.kt +++ b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/solver/BaseSolver.kt @@ -187,13 +187,19 @@ sealed class BaseSolver( // This cost is never applied if potential Handicap != 0 // It is fully applied if wbBalance(sP1) and wbBalance(sP2) are strictly of different signs // It is half applied if one of wbBalance is 0 and the other is >=2 - val potentialHd: Int = pairing.handicap.handicap(p1, p2) + val hd1 = pairing.handicap.handicap(p1, p2) + val hd2 = pairing.handicap.handicap(p2, p1) + val potentialHd: Int = max(hd1, hd2) val score = if (potentialHd == 0) { val wb1: Int = p1.colorBalance val wb2: Int = p2.colorBalance if (wb1 * wb2 < 0) colorBalanceWeight else if (wb1 == 0 && abs(wb2) >= 2 || wb2 == 0 && abs(wb1) >= 2) colorBalanceWeight / 2 else 0.0 - } else 0.0 + } else { + // apply a *big* score to let the stronger player have white + if (hd2 == 0) colorBalanceWeight * 10 + else 0.0 + } return score }