added iteratorcount prints

This commit is contained in:
Joachim 2018-08-28 07:27:44 +02:00
parent 7e33974d34
commit c4db0ec011
3 changed files with 14 additions and 0 deletions

View File

@ -8,6 +8,7 @@ class CrossSolverIterator : CrossSolver() {
*/ */
override fun solveCrosses(edgeModel: EdgeModel): Map<Int, IntArray> { override fun solveCrosses(edgeModel: EdgeModel): Map<Int, IntArray> {
val moveCounts = mutableMapOf<Int, IntArray>() val moveCounts = mutableMapOf<Int, IntArray>()
var iteratorCount = 0
for (moveCount in 1..8) { for (moveCount in 1..8) {
// build a counter of moveCount big // build a counter of moveCount big
@ -17,6 +18,7 @@ class CrossSolverIterator : CrossSolver() {
// count up, each state of the counter corresponds to a combination of moves // count up, each state of the counter corresponds to a combination of moves
while (iterator.hasNext()) { while (iterator.hasNext()) {
val moves = iterator.next() val moves = iterator.next()
iteratorCount++
// execute the moves // execute the moves
val afterMoves = edgeModel.doMoves(moves.toList()) val afterMoves = edgeModel.doMoves(moves.toList())
// check crosses that have not been found yet // check crosses that have not been found yet
@ -29,10 +31,14 @@ class CrossSolverIterator : CrossSolver() {
} }
} }
if (moveCounts.keys.size == 6) { if (moveCounts.keys.size == 6) {
println("iteratorCount = ${iteratorCount}")
return@solveCrosses moveCounts return@solveCrosses moveCounts
} }
} }
} }
println("iteratorCount = ${iteratorCount}")
return moveCounts return moveCounts
} }

View File

@ -9,6 +9,7 @@ class CrossSolverUpgraded : CrossSolver() {
override fun solveCrosses(edgeModel: EdgeModel): Map<Int, IntArray> { override fun solveCrosses(edgeModel: EdgeModel): Map<Int, IntArray> {
val moveCounts = mutableMapOf<Int, IntArray>() val moveCounts = mutableMapOf<Int, IntArray>()
var iteratorCount = 0
for (moveCount in 1..8) { for (moveCount in 1..8) {
println("all cross move count upgrade doing $moveCount") println("all cross move count upgrade doing $moveCount")
// build a counter of moveCount big // build a counter of moveCount big
@ -18,6 +19,7 @@ class CrossSolverUpgraded : CrossSolver() {
while (edgeModelFactory.hasNext()) { while (edgeModelFactory.hasNext()) {
// get the next model, using the internal counter which simply iterates over possible combinations of moves // get the next model, using the internal counter which simply iterates over possible combinations of moves
val next = edgeModelFactory.getNext() val next = edgeModelFactory.getNext()
iteratorCount++
// check crosses that have not been found yet // check crosses that have not been found yet
(0..5).forEach { color -> (0..5).forEach { color ->
@ -31,10 +33,12 @@ class CrossSolverUpgraded : CrossSolver() {
} }
// break if we have found hem all // break if we have found hem all
if (moveCounts.keys.size == 6) { if (moveCounts.keys.size == 6) {
println("iteratorCount = ${iteratorCount}")
return moveCounts return moveCounts
} }
} }
} }
println("iteratorCount = ${iteratorCount}")
return moveCounts return moveCounts
} }
} }

View File

@ -9,6 +9,7 @@ class CrossSolverUpgradedSkip : CrossSolver() {
override fun solveCrosses(edgeModel: EdgeModel): Map<Int, IntArray> { override fun solveCrosses(edgeModel: EdgeModel): Map<Int, IntArray> {
val moveCounts = mutableMapOf<Int, IntArray>() val moveCounts = mutableMapOf<Int, IntArray>()
var iteratorCount = 0
for (moveCount in 1..8) { for (moveCount in 1..8) {
println("all cross move count upgrade doing $moveCount") println("all cross move count upgrade doing $moveCount")
// build a counter of moveCount big // build a counter of moveCount big
@ -18,6 +19,7 @@ class CrossSolverUpgradedSkip : CrossSolver() {
while (edgeModelFactory.hasNext()) { while (edgeModelFactory.hasNext()) {
// get the next model, using the internal counter which simply iterates over possible combinations of moves // get the next model, using the internal counter which simply iterates over possible combinations of moves
val next = edgeModelFactory.getNext() val next = edgeModelFactory.getNext()
iteratorCount++
// check crosses that have not been found yet // check crosses that have not been found yet
(0..5).forEach { color -> (0..5).forEach { color ->
@ -31,10 +33,12 @@ class CrossSolverUpgradedSkip : CrossSolver() {
} }
// break if we have found hem all // break if we have found hem all
if (moveCounts.keys.size == 6) { if (moveCounts.keys.size == 6) {
println("iteratorCount = ${iteratorCount}")
return moveCounts return moveCounts
} }
} }
} }
println("iteratorCount = ${iteratorCount}")
return moveCounts return moveCounts
} }