qqwref
Legend
- Joined
- Dec 18, 2007
- Messages
- 7,834
- Location
- a <script> tag near you
- WCA ID
- 2006GOTT01
- YouTube
- Visit Channel
411 byte random-state scrambler for the 3x3x3. Probably can be golfed down a bit but at least this is kind of readable.
EDIT: ~680 move average out of 10 trials. The one I posted before that was based on doing cycles over and over had a ~1530 move average out of 10 trials.
Code:
r=Math.random
f=(b,a)=>{document.write((v=[[,"L2UL2","","L2U'L2","UFU'","U'B'U","R'","R","F'RF","R2","BR'B'","D2R2D2"],[,"R'","","F","F2","R","R2","D'R2D"]][b][a])+[["L2UL2U'L2B2U'B2DL2D'","ULU'L'B'UBLF'LFL2"],["F2UF2UF2U'R'U'RF2R'UR","R'F2L2D'L'DL'F2RU'","LF2R'DR'D'R2F2L'U'"]][b][0|r()*(2+b)]+v+v+v)}
g=(b,a)=>{j=0|r()*(a+1);f(b,a);j==a?f(b,a):j?(f(b,j),f(b,a)):1}
for(i=7;i---1;)g(1,i)
for(i=11;i---1;)g(0,i)
It's a Fisher–Yates shuffle done with Classic Pochmann. The f function swaps some piece with the buffer (UL or ULB) using a random one of (2 T perms or 3 Y perms) to give it a random orientation. The setup moves are all of order 2 or 4, so I can just do them 3 times to undo them. The g functions and the for loops do the actual shuffle; for a swap, there are 3 possible cases. If we swap two non-buffer pieces x and y, do f(x)f(y)f(x). If we swap a non-buffer piece x with the buffer, do f(x). And if we swap the piece x with itself, since we still need to orient, we want to do f(x)f(x). The buffer is always piece 0 so we can end the loop early and never need to worry about swapping it with itself (which is good, because the buffer's orientation is already set based on the other pieces).
EDIT: ~680 move average out of 10 trials. The one I posted before that was based on doing cycles over and over had a ~1530 move average out of 10 trials.
Last edited: