Fix players ID mismatch

This commit is contained in:
Claude Brisson
2024-03-24 14:28:25 +01:00
parent 208a912ad0
commit 3f0b8da68a

View File

@@ -314,7 +314,17 @@ class PairingTests: TestBase() {
val skipSeeding = round <= 2 val skipSeeding = round <= 2
assertTrue(compare_weights(getOutputFile("weights.txt"), getTestFile("opengotha/simplemm/simplemm_weights_R$round.txt"), skipSeeding), "Not matching opengotha weights for round $round") assertTrue(compare_weights(getOutputFile("weights.txt"), getTestFile("opengotha/simplemm/simplemm_weights_R$round.txt"), skipSeeding), "Not matching opengotha weights for round $round")
logger.info("Weights for round $round match OpenGotha") logger.info("Weights for round $round match OpenGotha")
assertTrue(compare_games(games, Json.parse(pairings[round - 1])!!.asArray(), skipColor=true),"pairings for round $round differ")
// fix players ids (TODO - reset memstore between each test for simplicity)
val maxId = games.flatMap { listOf((it as Json.Object).getInt("b")!!, (it as Json.Object).getInt("w")!!) }.max()
val fixedGames = games.mapTo(Json.MutableArray()) {
val game = it as Json.Object
Json.MutableObject(game)
.set("b", game.getInt("b")!! - maxId + 16)
.set("w", game.getInt("w")!! - maxId + 16)
}
assertTrue(compare_games(fixedGames, Json.parse(pairings[round - 1])!!.asArray(), skipColor=true),"pairings for round $round differ")
logger.info("Pairing for round $round match OpenGotha") logger.info("Pairing for round $round match OpenGotha")
forcedGames = Json.parse(pairings[round-1])!!.asArray() forcedGames = Json.parse(pairings[round-1])!!.asArray()