Remove games against ByePlayer when computing SOSOS and SODOS

This commit is contained in:
Quentin Rendu
2023-12-29 11:08:28 +01:00
parent 82dfe7d825
commit 43bd7c3dae
2 changed files with 23 additions and 16 deletions

View File

@@ -41,7 +41,7 @@ open class HistoryHelper(protected val history: List<List<Game>>, scoresGetter:
history.flatten().filter { game -> history.flatten().filter { game ->
game.handicap == 0 game.handicap == 0
}.filter { game -> }.filter { game ->
game.white != 0 game.white != 0 // Remove games against byePlayer
}.flatMap { game -> }.flatMap { game ->
listOf(Pair(game.white, +1), Pair(game.black, -1)) listOf(Pair(game.white, +1), Pair(game.black, -1))
}.groupingBy { }.groupingBy {
@@ -133,9 +133,13 @@ open class HistoryHelper(protected val history: List<List<Game>>, scoresGetter:
// sodos // sodos
val sodos by lazy { val sodos by lazy {
(history.flatten().map { game -> (history.flatten().filter { game ->
game.white != 0 // Remove games against byePlayer
}.map { game ->
Pair(game.black, if (game.result == Game.Result.BLACK) scores[game.white] ?: 0.0 else 0.0) Pair(game.black, if (game.result == Game.Result.BLACK) scores[game.white] ?: 0.0 else 0.0)
} + history.flatten().map { game -> } + history.flatten().filter { game ->
game.white != 0 // Remove games against byePlayer
}.map { game ->
Pair(game.white, if (game.result == Game.Result.WHITE) scores[game.black] ?: 0.0 else 0.0) Pair(game.white, if (game.result == Game.Result.WHITE) scores[game.black] ?: 0.0 else 0.0)
}).groupingBy { it.first }.fold(0.0) { acc, next -> }).groupingBy { it.first }.fold(0.0) { acc, next ->
acc + next.second acc + next.second
@@ -144,9 +148,13 @@ open class HistoryHelper(protected val history: List<List<Game>>, scoresGetter:
// sosos // sosos
val sosos by lazy { val sosos by lazy {
(history.flatten().map { game -> (history.flatten().filter { game ->
game.white != 0 // Remove games against byePlayer
}.map { game ->
Pair(game.black, sos[game.white] ?: 0.0) Pair(game.black, sos[game.white] ?: 0.0)
} + history.flatten().map { game -> } + history.flatten().filter { game ->
game.white != 0 // Remove games against byePlayer
}.map { game ->
Pair(game.white, sos[game.black] ?: 0.0) Pair(game.white, sos[game.black] ?: 0.0)
}).groupingBy { it.first }.fold(0.0) { acc, next -> }).groupingBy { it.first }.fold(0.0) { acc, next ->
acc + next.second acc + next.second

View File

@@ -119,16 +119,16 @@ sealed class BaseSolver(
val DEBUG_EXPORT_WEIGHT = true val DEBUG_EXPORT_WEIGHT = true
if (DEBUG_EXPORT_WEIGHT) { if (DEBUG_EXPORT_WEIGHT) {
//println("DUDD debug") println("DUDD debug")
//println(nameSortedPairables[2].nameSeed() + " " + nameSortedPairables[6].nameSeed()) println(nameSortedPairables[4].nameSeed() + " " + nameSortedPairables[25].nameSeed())
//pairing.main.applyDUDD(nameSortedPairables[2],nameSortedPairables[6], debug=true) pairing.main.applyDUDD(nameSortedPairables[25],nameSortedPairables[4], debug=true)
println("Standings debug: place Name group score ranking rating") println("Standings debug: place Name group score sos sosos ranking rating")
for (p in pairingSortedPairables){ for (p in pairingSortedPairables){
println(p.place.toString() + " " + p.nameSeed() + " " + p.group.toString() + " " + p.main.toString() + " " + p.displayRank() + " " + p.rating) println(p.place.toString() + " " + p.nameSeed() + " " + p.group.toString() + " " + p.main.toString() + " " + p.sos.toString() + " " + p.sosos.toString() + " " + p.displayRank() + " " + p.rating)
} }
println("Seeding debug") //println("Seeding debug")
pairing.main.applySeeding(nameSortedPairables[20],nameSortedPairables[9], debug=true) //pairing.main.applySeeding(nameSortedPairables[20],nameSortedPairables[9], debug=true)
pairing.main.applySeeding(nameSortedPairables[9],nameSortedPairables[20], debug=true) //pairing.main.applySeeding(nameSortedPairables[9],nameSortedPairables[20], debug=true)
var sumOfWeights = 0.0 var sumOfWeights = 0.0
println("name place ID colorBal group DUDD vs name place ID colorBal group DUDD") println("name place ID colorBal group DUDD vs name place ID colorBal group DUDD")
for (it in sorted) { for (it in sorted) {
@@ -251,7 +251,7 @@ sealed class BaseSolver(
return score return score
} }
open fun MainCritParams.applyDUDD(p1: Pairable, p2: Pairable): Double { open fun MainCritParams.applyDUDD(p1: Pairable, p2: Pairable, debug: Boolean =false): Double {
var score = 0.0 var score = 0.0
// TODO apply Drawn-Up/Drawn-Down if needed // TODO apply Drawn-Up/Drawn-Down if needed
@@ -332,8 +332,8 @@ sealed class BaseSolver(
score += 4 * duddWeight score += 4 * duddWeight
} }
/*
if(debug){ if(debug){
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("Names "+upperSP.nameSeed()+" "+upperSP.group+" "+lowerSP.nameSeed()+" "+lowerSP.group)
println("DUDD scenario, GroupDiff = "+scenario.toString()+" "+(upperSP.group-lowerSP.group).toString()) println("DUDD scenario, GroupDiff = "+scenario.toString()+" "+(upperSP.group-lowerSP.group).toString())
println("DUDD Upper/Lower modes = "+pairing.main.drawUpDownUpperMode.toString()+" "+pairing.main.drawUpDownLowerMode.toString()) println("DUDD Upper/Lower modes = "+pairing.main.drawUpDownUpperMode.toString()+" "+pairing.main.drawUpDownLowerMode.toString())
@@ -341,7 +341,6 @@ sealed class BaseSolver(
println("u/lSPplaceingroup = "+upperSP.placeInGroup.first.toString()+" "+lowerSP.placeInGroup.first.toString()) println("u/lSPplaceingroup = "+upperSP.placeInGroup.first.toString()+" "+lowerSP.placeInGroup.first.toString())
println("score = " + score.toString()) println("score = " + score.toString())
} }
*/
} }