Get sorted table numbers from OpenGotha

This commit is contained in:
Quentin Rendu
2023-10-19 10:52:17 +02:00
parent 426d88353c
commit 31f37a63ff
3 changed files with 30 additions and 16 deletions

View File

@@ -173,13 +173,19 @@ sealed class Solver(
val graph = builder.build()
val matching = KolmogorovWeightedPerfectMatching(graph, ObjectiveSense.MAXIMIZE)
val solution = matching.matching
val sorted = solution.map{
listOf(graph.getEdgeSource(it), graph.getEdgeTarget(it))
}.sortedWith(compareBy({ 0.5*(it[0].place + it[1].place) }, { min(it[0].place, it[1].place) }))
}.sortedWith(compareBy({ min(it[0].place, it[1].place) }))
val result = sorted.flatMap { games(white = it[0], black = it[1]) }
if (DEBUG_EXPORT_WEIGHT) {
for (it in sorted) {
println(it[0].nameSeed() + " " + it[0].place.toString() + " vs " +it[1].nameSeed() + " " +it[1].place.toString())
}
}
return result
}