• Welcome to SpeedSolving.com — the world’s largest puzzle community!

    You’re currently browsing as a guest, which means you have limited access to discussions, resources, member profiles, and community features.

    Join 50,000+ cubers and puzzle enthusiasts from around the world to ask questions, share solves, improve faster, and be part of the community.

    Registration is free, fast, and easy — create your account today.

    Already a member? Log in here to hide this message and start participating.

New Square-1 Scrambler!

masterofthebass

Premium Member
Joined
May 13, 2007
Messages
3,923
Location
Denver, CO
WCA
2007COHE01
YouTube
Visit Channel
After fumbling around with trying to translate Jaap's scrambler into better languages, I gave up and decided to write my own. I think it's much cleaner and much more understandable than Jaap's. Here's the python code if anyone wants to use it:

Code:
def scramblesq1():
    top=[1,1,0,1,1,0,1,1,0,1,1,0]
    bot=[1,0,1,1,0,1,1,0,1,1,0,1]
    topturn=0; botturn=0; start=False
    s=""
    i=0
    while i<40:
        while topturn==0 and botturn==0:
            turn=randint(0,11)
            while(canmove(top,turn)==False):
                turn=randint(0,11)
            topturn=turn
            turn=randint(0,11)
            while(canmove(bot,turn)==False):
                turn=randint(0,11)
            botturn=turn
            if topturn==0 and botturn==0 and i==0:
                start=True
                topturn=1
                botturn=1
        if start==False:
            if topturn!=0:
                i+=1
            if botturn!=0:
                i+=1
            top=shift(top, topturn)
            bot=shift(bot, botturn)
        top,bot=slice(top,bot)
        i+=1
        s+='(%d,%d) ' % ((topturn, topturn-12)[topturn>6], (botturn, botturn-12)[botturn>6])
        start=False
        topturn=0
        botturn=0
    return s
        
def slice(top, bot):
    newtop=[]; newbot=[]
    newbot.extend(bot[:6])
    newbot.extend(top[:6])
    newtop.extend(bot[6:])
    newtop.extend(top[6:])
    return newtop,newbot
    
def shift(face, amt):
    for x in range(amt):
        face.append(face.pop(0))
    return face
def canmove(face, amt):
    if amt>5:
        if face[amt] and face[amt-6]:
            return True
    else:
        if face[amt] and face[6+amt]:
            return True
    return False
 
O yeah, i do remember that. When i looked at it, I couldn't quite figure it out :p Too many ?: statements (which i didn't know existed at the time) ;) Looking at it, that seems like the direction I sort of wanted to go to, but I didn't like keeping track of the size of pieces. Here the array just shows when there's a seam in the ring of pieces. It checks if the opposite seam is open and there's your ability for a slice move :)
 
So now, could you describe this scrambling algorithm a bit? Or maybe comment the code so we can understand it a little bit more?
 
Ok. Basically you have 2 arrays: top and bottom. The 1s and 0s in them represent the "seams" between the pieces in each layer. I discovered that each half of the puzzle will always contain 180 degrees of pieces, so I have 12 30 degree numbers. At each point there is a seam (not a piece) there's a 1. In order for a slice move to be done on a face, the opposite spot needs to be a seam as well. The canmove function just sees if both spots of a new turn are 1s. If that turn is possible it saves that and does the same for the bottom. When you do a slice move the resulting array changes are done in the slice() function. There's a couple of other things to allow (0,0) at the start but not anywhere else. It's a pretty simple algorithm, which just came to me today.
 
Back
Top