"WCA Random Position 2x2x2 Cube scrambler"

TimS (2010-02-09 13:10:26 +0000)
Hardly "random" in its current state. Here's some source code from the scrambler: [code:19n0pmcr] function mix(){ initbrd(); for(var i=0;i<500;i++){ var f=Math.floor(Math.random()*3+3) + 16*Math.floor(Math.random()*3); domove(f); } } [/code:19n0pmcr] This is certainly not random-state. Looking at Jaap's solver, we should be generating positions directly from their permutation and orientation indices, not by applying 500 random moves and calling the result random. The code becomes shorter, anyways.
deadalnix (2010-02-24 17:01:07 +0000)
And on some system (some of them really unknown like windows 2000/xp), the random function isn't random.
Ron (2010-02-24 22:58:34 +0000)
I am actually surprised this is the case! Please someone in our community, help us solve this issue.
deadalnix (2010-03-21 18:54:08 +0000)
I have looked into the 2x2x2 source code scramble generator. The code is actually almost « ununderstandable ». All vars have uniletters names. I'm pretty sure I can solve this problem with some explainations on the actual code. However, I have an alternative scramble generator for 2x2x2 and I can share it with WCA if this is a possible solution. This generator actually use a really random position. I think we should adress both this issue and the minimal number of moves for a scramble at once and modifiy the scrambler one time.
Ron (2010-04-11 19:26:54 +0000)
As soon as we have a new and better version we will use it. Until then we stick with the current program.
TimS (2010-04-11 22:28:37 +0000)
Whoever coded the scrambler is dumb. I'll rewrite it when I have the time.
deadalnix (2010-04-12 00:10:03 +0000)
I don't think this person is dumb. He does a great job in computing puzzle in general. Anyway, here is a proposition : http://deadal.nix.free.fr/solver/solver.html But the regulation about minimal number of turn should be finalized before changing scrambler. This solver is using the système random number generator. It have to be changed in the final version, because this random number generator is known to be flawed on some systems (win2k and xp, whih are very commons OS).
Ron (2010-04-12 09:58:30 +0000)
Hi Deadalnix, Thanks for your contribution. If your program is better then we should use it as soon as possible. First we need to check whether it is indeed better. - Please tell us which changes you made, and how this program in an improvement? - Could some other members please check out the code? There is no need to accept this software before finalising WCA Regulations 2010. I can add it later. Thanks, Ron
deadalnix (2010-04-12 14:27:43 +0000)
Hi Ron, This program is not based on the one from the wca. I have done this program some time ago to learn more about computing puzzles, and 2x2x2 is pretty simple, so this is a good start. The algorithm used to generate the scramble is the following one : Each possible pemutaion have an index, in [0;5040] (5040 is 7!) Each possible orientation have an index in [0;729] (729 is 3^6) First of all, the script create a transition table for permutaion and orientation from a natural representation of the puzzle to an indexed one. This allow a big speedup in computing the puzzle for next steps. Then, the script initialize a pruning table, by exploring the puzzle. This prunning table can be used to remove very easy scrambles, like suggested in another thread. When all is initialized, the script generate 2 random numbers, one for permutaion and one for orientation. Then, this random position is solved to generate a scramble. The script wasn't supposed to be released to many poeple, it was more a learning project at first. But if this can help here, I'm happy to share it.
Ron (2010-04-13 05:53:54 +0000)
Hi Deadalnix, Thanks for the information. This subject is on my TO DO list, so it will be covered as soon as possible given my limited time. First we are organising German Open and Slovenian Open. Busy schedule. Any feedback from members of our community is very welcome of course. Have fun, Ron
Cride5 (2010-04-14 10:41:26 +0000)
This issue was discussed on the speedsolving forum a wee while ago. Discussion starts here: http://www.speedsolving.com/forum/showt ... post313973 The problem certainly isn't with the solver. Jaap's 2x2 javascript solver is the most efficient one I've seen and seems to be capable of generating solutions almost instantly. The problem was in cube randomiser, which simply applies 500 random moves. A random-state scrambler needs to generate a random cube state. I'm using jaap's solver in my cTimer javascript application, but I modified the scrambling part to generate a random cube state. Code here: http://www.ctimer.co.uk/solver2x2.js Although this is guaranteed to generate random cube states (given a truly random number generator), it is a little bloated. As Swordsman Kirby pointed out on the speedsolving forum the method I used didn't take advantage of how Jaap's algorithm works. It stores cube state in two lookup tables. One for orientation and another for permutation. Generating a random cube state is a simple is generating a random index into each of the tables. I haven't had time to code this improvement into my scrambler, but perhaps if you PM Swordsman Kirby, he may already have an implementation to hand... EDIT: I've updated my 2x2 scrambler for cTimer to generate a random position using the method proposed by SK. A page for generating scrambles is here: http://www.ctimer.co.uk/solver2x2.html The timer app which uses it is here: http://www.ctimer.co.uk The new code is here: http://www.ctimer.co.uk/solver2x2.js ... to make use of the code, simply include solver2x2.js in your application and make a call to: initSolver2x2() on page load, then use calls to genScramble2x2() to return your scramble. Currently it doesn't filter easy scrambles, but if this is wanted I can add it no probs. Hope this helps...
deadalnix (2010-04-14 11:46:12 +0000)
Hi cride, Sure we can do that with jaap solver. The reason is quite simple : both mine and Jaap's work mostly the same way. However, I'm not sure jaap's have the ability to filter scramble.
Cride5 (2010-04-14 12:09:13 +0000)
[quote="deadalnix":rf8r0hj5]Hi cride, [b:rf8r0hj5]Sure we can do that with jaap solver.[/b:rf8r0hj5] The reason is quite simple : both mine and Jaap's work mostly the same way. However, I'm not sure jaap's have the ability to filter scramble.[/quote:rf8r0hj5] Yes, we can now. Just pass an integer to the genScramble2x2 method to impose a limit.
Pedro_S (2010-04-14 13:52:35 +0000)
[quote="deadalnix":1t2gju0q]I don't think this person is dumb. He does a great job in computing puzzle in general. Anyway, here is a proposition : http://deadal.nix.free.fr/solver/solver.html But the regulation about minimal number of turn should be finalized before changing scrambler. This solver is using the système random number generator. It have to be changed in the final version, because this random number generator is known to be flawed on some systems (win2k and xp, whih are very commons OS).[/quote:1t2gju0q] I can't open this, the browser crashes and I have to interrupt the script. Will try at home, later.
Cride5 (2010-04-14 18:43:43 +0000)
OK, so I made a minor change to the existing WCA 2x2 scrambler to do random-state scrambles. The only part of the original code which has changed is the mix() function. It is now replaced by mix2() which generates a random cube state rather than applying 500 random moves. The altered scrambler is available here: http://dl.dropbox.com/u/4352576/rstate2 ... e_222.html ... and the code with changes made can be downloaded from: http://dl.dropbox.com/u/4352576/rstate2x2.zip I didn't use the Swordsman Kirby's suggested method for generating the random state, since its efficiency is based on the simulator only using the cube represented in index format. For example, at the moment the system it works by doing: mix() >> [i:10mfcvx4]facelet form[/i:10mfcvx4] >> convert() >> [i:10mfcvx4]cubie form[/i:10mfcvx4] >> convert() >> [i:10mfcvx4]index from[/i:10mfcvx4] >> solve() Using SK's method cuts all this out by doing: mix() >> [i:10mfcvx4]index form[/i:10mfcvx4] >> solve() ...a huge saving! Unfortunately, the cube image generator which comes as part of the scrambler app needs the cube in facelet form. Using SK's method with this app would mean that image generation would require: mix() >> [i:10mfcvx4]index form[/i:10mfcvx4] >> convert() >> [i:10mfcvx4]cubie form[/i:10mfcvx4] >> convert() >> [i:10mfcvx4]facelet form[/i:10mfcvx4] >> generate_images() ... since all the conversions need to happen in reverse, most of the efficiency savings are lost. The new mix() function generates a cube in facelet form like before, so that it can be replaced with the original mix() function without changing anything else, and without having to write new code to convert in the opposite direction (from index form to facelet form). It may be marginally more efficient to use SK's method to generate the random state, and then convert back into facelet form for image generation, but it would require quite a few changes to the existing code.
deadalnix (2010-04-14 20:24:30 +0000)
How jaap solver handle prunning ?
Cride5 (2010-04-15 11:47:33 +0000)
Well currently, when the 'minimum scramble length' field is set the scrambler will achieve this by generating a sub-optimal scramble for cube states which require less moves than the limit to solve. It effectively 'hides' the fact that an easy scramble can be solved an few moves. I would propose that instead of operating in this way, the system should actually remove cube states which give optimal solutions are below the move limit, rather than simply generating longer (sub-optimal) scrambles. This would be trivial to implement into the existing scramble program if required - as demonstrated by the code here: http://www.ctimer.co.uk/solver2x2.js
Ron (2010-04-15 11:56:06 +0000)
Thanks Conrad. We need some confirmation before we start using it. The code looks pretty clean to me. Could anyone please give some feedback on the following questions: 1) does the code indeed use a correct way to generate random positions? 2) is the code quality good enough? 3) does the program work correctly for you? Thanks, Ron
deadalnix (2010-04-15 12:42:45 +0000)
Given a true random number generator, both solution generate true random scramble. Modifie jaap's scrambler doesn't use the same prunning solution. This makes the scrambler lighter to initialise, but disallow the implementation of some functionnality. Both work fine to me in chrome 5 and firefox 3.5 .
MadsMohr (2010-04-16 07:52:23 +0000)
Conrad has made a random state scrambler for 2x2x2: http://www.speedsolving.com/forum/showt ... post361541
Ron (2010-04-16 09:06:29 +0000)
Conrad is Cride5
Ron (2010-05-09 11:37:49 +0000)
Hi Conrad, I got the confirmation by Jaap that your code is indeed correct. Please e-mail me the files I need to post. Thanks for your contribution. Ron
Cookies help us deliver our services. By using our services, you agree to our use of cookies.