no checks is faster than all checks :(

This commit is contained in:
Joachim 2018-08-25 22:19:49 +02:00
parent 532b1cb85f
commit d5a771ff14

View File

@ -17,7 +17,9 @@ class CounterSkip(size: Int): Counter(size, 18) {
var last = super.increase() var last = super.increase()
lmi = min(lastModifiedIndex, lmi) lmi = min(lastModifiedIndex, lmi)
// are we having an invalid situation? this would be two consecutive moves on the same face // are we having an invalid situation? this would be two consecutive moves on the same face
while (containsConsecutiveSameFaceMoves() && !atMax()) { while (
(containsConsecutiveSameFaceMoves() && !atMax()) ||
(this.counter?.size > 1 && !atMax() && containsPalindrome())) {
last = super.increase() last = super.increase()
lmi = min(lastModifiedIndex, lmi) lmi = min(lastModifiedIndex, lmi)
} }
@ -26,6 +28,15 @@ class CounterSkip(size: Int): Counter(size, 18) {
return last return last
} }
private fun containsPalindrome(): Boolean {
val i1 = this.counter.size / 2
for (i in 0 until i1) {
if (this.counter[i] != this.counter[this.counter.size - 1 - i])
return false
}
return true
}
/** /**
* Are there two moves in the current counter / chain that act on the same face? This would be F+F2 for example. * Are there two moves in the current counter / chain that act on the same face? This would be F+F2 for example.
*/ */