diff --git a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/Random.kt b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/Random.kt index 0a0af21..35a32b7 100644 --- a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/Random.kt +++ b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/Random.kt @@ -3,7 +3,7 @@ package org.jeudego.pairgoth.pairing import org.jeudego.pairgoth.model.Pairable import org.jeudego.pairgoth.pairing.solver.BaseSolver -fun detRandom(max: Double, p1: Pairable, p2: Pairable): Double { +fun detRandom(max: Double, p1: Pairable, p2: Pairable, symmetric: Boolean): Double { var inverse = false var name1 = p1.fullName("") var name2 = p2.fullName("") @@ -15,7 +15,8 @@ fun detRandom(max: Double, p1: Pairable, p2: Pairable): Double { c.code.toDouble() * (i + 1) }.sum() * 1234567 % (max + 1) // we want the symmetry, except when explicitly asked for a legacy asymmetric detRandom, for tests - if (inverse && BaseSolver.asymmetricDetRandom) { + // if (inverse && BaseSolver.asymmetricDetRandom) { + if (inverse && !symmetric) { nR = max - nR } return nR 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 a44e6db..adcbf1a 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 @@ -210,7 +210,7 @@ sealed class BaseSolver( } open fun BaseCritParams.applyRandom(p1: Pairable, p2: Pairable): Double { - val score = if (deterministic) detRandom(random, p1, p2) + val score = if (deterministic) detRandom(random, p1, p2, true) else nonDetRandom(random) return score } @@ -404,9 +404,9 @@ sealed class BaseSolver( val rand = if (asymmetricDetRandom && p1.fullName() > p2.fullName()) { // for old tests to pass - detRandom(randRange, p2, p1) + detRandom(randRange, p2, p1, false) } else { - detRandom(randRange, p1, p2) + detRandom(randRange, p1, p2, true) } maxSeedingWeight - rand } else { @@ -546,7 +546,7 @@ sealed class BaseSolver( } else if (p1.colorBalance < p2.colorBalance) { score = 1.0 } else { // choose color from a det random - if (detRandom(1.0, p1, p2) === 0.0) { + if (detRandom(1.0, p1, p2, false) === 0.0) { score = 1.0 } else { score = -1.0