small speedup achieved, can now eliminate same-face combinations from investigated solutions

This commit is contained in:
Joachim 2018-08-25 10:52:34 +02:00
parent 60b2b3bb1a
commit ff81c3e7c8
3 changed files with 8 additions and 6 deletions

View File

@ -31,9 +31,8 @@ class CounterSkipSameFaces(size: Int, base: Int = 10): Counter(size, base) {
*/
private fun containsConsecutiveSameFaceMoves(): Boolean {
for (i in 1 until this.counter.size) {
val current = Move.values()[this.counter[i]]
val previous = Move.values()[this.counter[i - 1]]
if (current sameFace previous)
// perhaps is a speedup
if(this.counter[i]%6 == this.counter[i-1]%6)
return true
}
return false

View File

@ -21,7 +21,7 @@ open abstract class CrossSolver {
fun printResults(results: Map<Int, List<Move>>) {
println("results: ")
results.forEach { color, moveList ->
println("> color ${colorLetter(color)}, moves $moveList")
println("> color ${colorLetter(color)}, moves (${moveList.size}) $moveList")
}
}
}

View File

@ -6,7 +6,10 @@ import java.util.*
* All the possible moves on the cube.
*/
enum class Move {
F, F_, F2, B, B_, B2, L, L_, L2, R, R_, R2, U, U_, U2, D, D_, D2;
// these are purposely put in this order: Move.index % 6 will result in the same value for the same face
F, B, U, D, L, R,
F_, B_, U_, D_, L_, R_,
F2, B2, U2, D2, L2, R2;
/**
* Static methods for the Move object.