From f2e9cd5acce0ed69d93a424c136711e5fc0a57ae Mon Sep 17 00:00:00 2001 From: Claude Brisson Date: Thu, 25 Jan 2024 08:22:48 +0100 Subject: [PATCH] Fix handicap bug --- .../org/jeudego/pairgoth/model/Tournament.kt | 2 +- .../jeudego/pairgoth/pairing/solver/BaseSolver.kt | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/model/Tournament.kt b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/model/Tournament.kt index a04e5cc..4afe9a2 100644 --- a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/model/Tournament.kt +++ b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/model/Tournament.kt @@ -89,7 +89,7 @@ sealed class Tournament ( val white = solver.pairables.find { p-> p.id == game.white }!! val black = solver.pairables.find { p-> p.id == game.black }!! game.drawnUpDown = solver.dudd(black, white) - game.handicap = solver.hd(black, white) + game.handicap = solver.hd(white = white, black = black) } fun usedTables(round: Int): BitSet = 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 2090a21..41a43f9 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 @@ -186,8 +186,8 @@ 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 hd1 = pairing.handicap.handicap(p1, p2) - val hd2 = pairing.handicap.handicap(p2, p1) + val hd1 = pairing.handicap.handicap(white = p1, black = p2) + val hd2 = pairing.handicap.handicap(white = p2, black = p1) val potentialHd: Int = max(hd1, hd2) val score = if (potentialHd == 0) { val wb1: Int = p1.colorBalance @@ -505,7 +505,7 @@ sealed class BaseSolver( open fun HandicapParams.color(p1: Pairable, p2: Pairable): Double { var score = 0.0 - val hd = pairing.handicap.handicap(p1,p2) + val hd = pairing.handicap.handicap(white = p1, black = p2) if(hd==0){ if (p1.colorBalance > p2.colorBalance) { score = - 1.0 @@ -537,13 +537,13 @@ sealed class BaseSolver( } //return white.group - black.group } - fun hd(black: Pairable, white: Pairable): Int { - return pairing.handicap.handicap(white, black) + fun hd(white: Pairable, black: Pairable): Int { + return pairing.handicap.handicap(white = white, black = black) } - open fun games(black: Pairable, white: Pairable): List { + open fun games(white: Pairable, black: Pairable): List { // CB TODO team of individuals pairing val table = if (black.id == 0 || white.id == 0) 0 else usedTables.nextClearBit(1) usedTables.set(table) - return listOf(Game(id = Store.nextGameId, table = table, black = black.id, white = white.id, handicap = hd(white, black), drawnUpDown = dudd(black, white))) + return listOf(Game(id = Store.nextGameId, table = table, black = black.id, white = white.id, handicap = hd(white = white, black = black), drawnUpDown = dudd(black, white))) } }