WCA official scrambler broken?

Eleredo

Regular
Joined
Jun 20, 2010
Messages
227
Location
Belgium
I was scrambling my 7x7x7 using the WCA scrambler (so I can see whether I scrambled it correctly). I saw something funny:

magil3.jpg


Anyone else noticed this too?
 
I think I found the problem - it's in the scramblestring function.

Code:
if( k && size<=5 && !mult ) {
	s+="dlburf".charAt(j);
}else{
	if(size<=5 && mult ){
		s+="DLBURF".charAt(j);
		if(k) s+="w";
	}else{
		if(k)	s+=(k+1);
		s+="DLBURF".charAt(j);
	}
}

So, normally, k is an integer specifying the "depth" of this turn, and this works perfectly. Now I'm not really sure why, but sometimes if(k) turns out false, even though if(k>0) turns out true. This shouldn't be happening, but for some reason, it is. I replaced all the if(k) with if(k>0) and the problem went away:

Code:
if( k>0 && size<=5 && !mult ) {
	s+="dlburf".charAt(j);
}else{
	if(size<=5 && mult ){
		s+="DLBURF".charAt(j);
		if(k>0) s+="w";
	}else{
		if(k>0)	s+=(k+1);
		s+="DLBURF".charAt(j);
	}
}

My guess as to the cause: a more recent version of javascript (or an internet browser?) created some kind of way where, even though k is a positive integer, if(k) might be false but if(k>0) might be true. The problem with the scrambler didn't happen before because this wasn't an issue before.
 
My guess as to the cause: a more recent version of javascript (or an internet browser?) created some kind of way where, even though k is a positive integer, if(k) might be false but if(k>0) might be true. The problem with the scrambler didn't happen before because this wasn't an issue before.

Great detective work!
 
Tim Reynolds noticed that a few weeks ago as well and I traced it back to the same point in the code. I'm no javascript expert, but in my view, it's clearly a bug in Firefox's javascript engine (several of us were able to get failures in Firefox but not in other browsers, and the thread starter here used Firefox as well). A value of 1 or 2 should definitely be considered true. I tried to recreate the problem with a short program to submit a bug report, but I couldn't (and then I left to America).
 
Last edited:
Back
Top