MMS up to round 4 out of 5 (bug with BWbalance)
This commit is contained in:
@@ -73,9 +73,10 @@ object PairingHandler: PairgothApiHandler {
|
||||
}.toSet()
|
||||
game.black = payload.getID("b") ?: badRequest("missing black player id")
|
||||
game.white = payload.getID("w") ?: badRequest("missing white player id")
|
||||
tournament.recomputeDUDD(round, game.id)
|
||||
|
||||
tournament.recomputeHdAndDUDD(round, game.id)
|
||||
// temporary
|
||||
payload.getInt("dudd")?.let { game.drawnUpDown = it }
|
||||
//payload.getInt("dudd")?.let { game.drawnUpDown = it }
|
||||
val black = tournament.pairables[game.black] ?: badRequest("invalid black player id")
|
||||
val white = tournament.pairables[game.black] ?: badRequest("invalid white player id")
|
||||
if (black.skip.contains(round)) badRequest("black is not playing this round")
|
||||
|
@@ -71,7 +71,7 @@ sealed class Tournament <P: Pairable>(
|
||||
else mutableMapOf<ID, Game>().also { games.add(it) }
|
||||
fun lastRound() = games.size
|
||||
|
||||
fun recomputeDUDD(round: Int, gameID: ID) {
|
||||
fun recomputeHdAndDUDD(round: Int, gameID: ID) {
|
||||
// Instantiate solver with game history
|
||||
// TODO cleaner solver instantiation
|
||||
val history = historyBefore(round)
|
||||
@@ -81,11 +81,12 @@ sealed class Tournament <P: Pairable>(
|
||||
MacMahonSolver(round, history, pairables.values.toList(), pairing.pairingParams, pairing.placementParams, pairing.mmFloor, pairing.mmBar)
|
||||
} else throw Exception("Invalid tournament type")
|
||||
|
||||
// Recomputes DUDD
|
||||
// Recomputes DUDD and hd
|
||||
val game = games(round)[gameID]!!
|
||||
val whiteplayer = solver.pairables.find { p-> p.id == game.white }!!
|
||||
val blackplayer = solver.pairables.find { p-> p.id == game.black }!!
|
||||
game.drawnUpDown = solver.dudd(blackplayer, whiteplayer)
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -41,7 +41,7 @@ open class HistoryHelper(protected val history: List<List<Game>>, scoresGetter:
|
||||
history.flatten().filter { game ->
|
||||
game.handicap == 0
|
||||
}.filter { game ->
|
||||
game.white != 0 // Remove games against byePlayer
|
||||
game.white != ByePlayer.id // Remove games against byePlayer
|
||||
}.flatMap { game ->
|
||||
listOf(Pair(game.white, +1), Pair(game.black, -1))
|
||||
}.groupingBy {
|
||||
|
@@ -184,6 +184,9 @@ 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
|
||||
if (p1.name == "Marechal" && p2.name == "Goloubkov") {
|
||||
println("coucou ${p1.colorBalance} ${p2.colorBalance}")
|
||||
}
|
||||
val hd1 = pairing.handicap.handicap(p1, p2)
|
||||
val hd2 = pairing.handicap.handicap(p2, p1)
|
||||
val potentialHd: Int = max(hd1, hd2)
|
||||
@@ -331,7 +334,7 @@ sealed class BaseSolver(
|
||||
score += 4 * duddWeight
|
||||
}
|
||||
|
||||
/*if(true) {
|
||||
/*if(p1.name == "Durand" && p2.name == "Aim") {
|
||||
println("Names DU DD "+p1.nameSeed()+" "+p1_DU+" "+p1_DD+" "+p2.nameSeed()+" "+p2_DU+" "+p2_DD)
|
||||
println("Names "+upperSP.nameSeed()+" "+upperSP.group+" "+lowerSP.nameSeed()+" "+lowerSP.group)
|
||||
println("DUDD scenario, GroupDiff = "+scenario.toString()+" "+(upperSP.group-lowerSP.group).toString())
|
||||
@@ -526,13 +529,23 @@ sealed class BaseSolver(
|
||||
}
|
||||
|
||||
fun dudd(black: Pairable, white: Pairable): Int {
|
||||
return white.group - black.group
|
||||
return if (white.main > black.main) {
|
||||
1
|
||||
} else if (white.main < black.main) {
|
||||
-1
|
||||
} else {
|
||||
0
|
||||
}
|
||||
//return white.group - black.group
|
||||
}
|
||||
fun hd(black: Pairable, white: Pairable): Int {
|
||||
return pairing.handicap.handicap(white, black)
|
||||
}
|
||||
open fun games(black: Pairable, white: Pairable): List<Game> {
|
||||
// CB TODO team of individuals pairing
|
||||
val usedTables = tables.getOrNull(round - 1) ?: BitSet().also { tables.add(it) }
|
||||
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 = pairing.handicap.handicap(white, black), drawnUpDown = dudd(black, white)))
|
||||
return listOf(Game(id = Store.nextGameId, table = table, black = black.id, white = white.id, handicap = hd(white, black), drawnUpDown = dudd(black, white)))
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user