maxcube
Regular
I am creating a Rubik's program thingy
and I need to know how to generate scrambles. Completely random? Certain alg? How? Thank you very much!
EDIT: This is for 3x3
EDIT: This is for 3x3
Last edited:
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
previousMove = 0
for scrambleLength{
currentMove = random(1,3)
while currentMove=previousMove {
currentMove = random(1,3)
}
modifier = random(1,3)
movePart2 = random(1,2)
if(movePart2==1){
if(currentMove==1){
print "F"
}
if(currentMove==2){
print "R"
}
if(currentMove==3){
print "U"
}
}else{
if(currentMove==1){
print "B"
}
if(currentMove==2){
print "L"
}
if(currentMove==3){
print "D"
}
}
if(modifier==2){
print "'"
}
if(modifier==3){
print "2"
}
print " "
previousMove = currentMove
}
Maybe because they are full of unnecessary ugly hacks and not very easy to understand?Why don't you just look at the source of the official wca scramblers? They are written in javascript and all have a scramble-function
http://www.geocities.com/jaapsch/puzzles/compcube.htm#scrambling
Maybe because they are full of unnecessary ugly hacks and not very easy to understand?Why don't you just look at the source of the official wca scramblers? They are written in javascript and all have a scramble-function
Dim currentMove As Integer
Dim PrevMove As Integer
Dim modifier As Integer
Dim movepart2 As Integer
Label1 = ""
'---
PrevMove = 0
For i = 1 To 25
Randomize
currentMove = (2 * Rnd)
While currentMove = PrevMove
currentMove = (2 * Rnd)
Wend
modifier = (2 * Rnd)
movepart2 = (1 * Rnd)
If movepart2 = 0 Then
Select Case currentMove
Case 0
Label1 = Label1 + "F"
Case 1
Label1 = Label1 + "R"
Case 2
Label1 = Label1 + "U"
End Select
Else
Select Case currentMove
Case 0
Label1 = Label1 + "B"
Case 1
Label1 = Label1 + "L"
Case 2
Label1 = Label1 + "D"
End Select
End If
If modifier = 1 Then
Label1 = Label1 + "'"
End If
If modifier = 2 Then
Label1 = Label1 + "2"
End If
Label1 = Label1 + " "
PrevMove = currentMove
Next i
Why?i'v just converted that code up there into a visual basic code
LOL!Why?i'v just converted that code up there into a visual basic code
def randomtwist():
axes = "xxxyyyzz"
faces = { "x": ('L', 'R'),
"y": ('U', 'D'),
"z": ('F', 'B') }
directions = ('', "'", '2')
axis = ""
last = ""
while True:
while (axis == last):
axis,direction = choice(axes),choice(directions)
face = choice(faces[axis])
last = axis
yield (face + direction)
def scramble(min = 25, max = 25):
from random import randint
count = randint(min, max)
seq = []
for twist in randomtwist():
seq.append(twist)
if (len(seq) > count):
break
return " ".join(seq)