Etotheipi
Veteran
Yay! I think I got R and y working, so now I can make all face turns, which is good enough for now, I'll get slice moves working later. Can someone link me the RLFB only U and D algs?
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.

Why not do x' y' R y x?Yay! I think I got R and y working, so now I can make all face turns, which is good enough for now, I'll get slice moves working later. Can someone link me the RLFB only U and D algs?
I've only programmed y and R. Also, for some reason my code is doing an L' when I do y2 R y2. hmmWhy not do x' y' R y x?
ThanksR L F2 B2 R' L' D R L F2 B2 R' L'
Maybe your function that compacts an alg isn't working?I've only programmed y and R. Also, for some reason my code is doing an L' when I do y2 R y2. hmm
Ya since I manually coded y, and since y moves every piece on the cube except two centers, its super long and theres lots of room for mistakes. Though I don't really know how the y moves would cause the problem I have. I'll check the compactor thingy.Maybe your function that compacts an alg isn't working?
SOLVED = ['w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'g', 'g', 'g', 'g',
'g', 'g', 'g', 'g', 'g', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b',
'b', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o']
class Move:
def __init__(self, indices):
self.indices = indices
def inverted(self):
inverted = []
for item in self.indices: inverted.append((item[1], item[0]))
return Move(inverted)
class Cube():
def __init__(self, state=SOLVED):
self.state = state[:]
def move(self, move): # Function which applies a move to the cube object, takes a move object as its parameter
cube = self.state[:]
indices = move.indices
next_cube = cube[:]
for item in indices:
next_cube[item[1]] = cube[item[0]]
self.state = next_cube[:]
def sequence(self, sequence):
for move in sequence:
self.move(move)
def move_from_sequence(sequence): # Turns a list of move objects into a single move object
cube = Cube()
cycle = 0
new_indices = []
item = ()
for sticker in cube.state:
cube.state[cycle] = (sticker, cycle)
cycle += 1
cube.sequence(sequence)
cycle = 0
for sticker in cube.state:
item = cube.state[cycle]
if cycle != item[1]:
new_indices.append((item[1], cycle))
cycle += 1
cube.state = SOLVED[:]
return Move(new_indices)
def cy(targets): # Makes manually coding moves easier by automating cycles of stickers, so you don't have to code
# every swap by hand
out = []
for i in range(len(targets)): out.append((targets[i], targets[(i + 1) % len(targets)]))
return out
# Manually coded moves:
R = Move(
[(8, 36), (5, 39), (2, 42), (36, 17), (39, 14), (42, 11), (17, 26), (14, 23), (11, 20), (26, 8), (23, 5), (20, 2),
(27, 29), (29, 35), (35, 33), (33, 27), (28, 32), (32, 34), (34, 30), (30, 28)])
y = Move(
[(0, 2), (2, 8), (8, 6), (6, 0), (1, 5), (5, 7), (7, 3), (3, 1), (9, 15), (15, 17), (17, 11), (11, 9), (10, 12),
(12, 16), (16, 14), (14, 10), (20, 47), (19, 46), (18, 45), (47, 38), (46, 37), (45, 36), (38, 29), (37, 28),
(36, 27), (29, 20), (28, 19), (27, 18), (23, 50), (22, 49), (21, 48), (50, 41), (49, 40), (48, 39), (41, 32),
(40, 31), (39, 30), (32, 23), (31, 22), (30, 21), (26, 53), (25, 52), (24, 51), (53, 44), (52, 43), (51, 42),
(41, 32), (43, 34), (44, 35), (42, 33), (35, 26), (34, 25), (33, 24)])
x = Move(
cy([20, 2, 42, 11]) + cy([19, 1, 43, 10]) + cy([18, 0, 44, 9]) + cy([23, 5, 39, 14]) + cy([22, 4, 40, 13]) + cy(
[21, 3, 41, 12]) + cy([27, 29, 35, 33]) + cy([28, 32, 34, 30]) + cy([45, 51, 53, 47]) + cy(
[46, 48, 52, 50]) + cy([26, 8, 36, 17]) + cy([25, 7, 37, 16]) + cy([24, 6, 38, 15]))
# Other moves out of the manually coded moves:
# x move setup
x2 = move_from_sequence([x, x])
x_ = x.inverted
# R move setup
R_ = R.inverted()
R2 = move_from_sequence([R, R])
# y move setup
y2 = move_from_sequence([y, y])
y_ = y.inverted()
# L move setup
L = move_from_sequence([y2, R, y2])
L_ = L.inverted()
L2 = move_from_sequence([L, L])
# F move setup
F = move_from_sequence([y_, R, y])
F2 = move_from_sequence([F, F])
F_ = F.inverted()
# B move setup
B = move_from_sequence([y, R, y_])
B_ = B.inverted()
B2 = move_from_sequence([B, B])
# U move setup
U = move_from_sequence([x_, y_, R, y, x]) # The code breaks down when I start using x moves, I don't know why.
U_ = U.inverted()
U2 = move_from_sequence([U, U])
# D move setup
D = move_from_sequence([x2, U, x2])
D_ = D.inverted()
D2 = move_from_sequence([D, D])
# M move setup
M = move_from_sequence([R, L_, x_])
M_ = M.inverted()
M2 = move_from_sequence([M, M])
z = move_from_sequence([x, y, x_])
z_ = z.inverted()
z2 = move_from_sequence([z, z])
Traceback (most recent call last):
File "C:/Users/[Redacted cause it had my last name]/PycharmProjects/SalmonCube/SalmonCube.py", line 108, in <module>
U = move_from_sequence([x_, y_, R, y, x]) # The code breaks down when I start using x moves, I don't know why.
File "C:/Users/[Redacted]/PycharmProjects/SalmonCube/SalmonCube.py", line 42, in move_from_sequence
cube.sequence(sequence)
File "C:/Users/[Redacted]/PycharmProjects/SalmonCube/SalmonCube.py", line 30, in sequence
self.move(move)
File "C:/Users/[Redacted]/PycharmProjects/SalmonCube/SalmonCube.py", line 22, in move
indices = move.indices
AttributeError: 'function' object has no attribute 'indices'
I dunno if I'm just being dumb, but it looks like Cube.move() has no attribute "indices"I finished making x, y and R moves, so I made all the other moves, but it's giving me errors on the line where I first make other moves using x moves, and I have no idea why. Heres my code and the error log:
Python:SOLVED = ['w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'g', 'g', 'g', 'g', 'g', 'g', 'g', 'g', 'g', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o'] class Move: def __init__(self, indices): self.indices = indices def inverted(self): inverted = [] for item in self.indices: inverted.append((item[1], item[0])) return Move(inverted) class Cube(): def __init__(self, state=SOLVED): self.state = state[:] def move(self, move): # Function which applies a move to the cube object, takes a move object as its parameter cube = self.state[:] indices = move.indices next_cube = cube[:] for item in indices: next_cube[item[1]] = cube[item[0]] self.state = next_cube[:] def sequence(self, sequence): for move in sequence: self.move(move) def move_from_sequence(sequence): # Turns a list of move objects into a single move object cube = Cube() cycle = 0 new_indices = [] item = () for sticker in cube.state: cube.state[cycle] = (sticker, cycle) cycle += 1 cube.sequence(sequence) cycle = 0 for sticker in cube.state: item = cube.state[cycle] if cycle != item[1]: new_indices.append((item[1], cycle)) cycle += 1 cube.state = SOLVED[:] return Move(new_indices) def cy(targets): # Makes manually coding moves easier by automating cycles of stickers, so you don't have to code # every swap by hand out = [] for i in range(len(targets)): out.append((targets[i], targets[(i + 1) % len(targets)])) return out # Manually coded moves: R = Move( [(8, 36), (5, 39), (2, 42), (36, 17), (39, 14), (42, 11), (17, 26), (14, 23), (11, 20), (26, 8), (23, 5), (20, 2), (27, 29), (29, 35), (35, 33), (33, 27), (28, 32), (32, 34), (34, 30), (30, 28)]) y = Move( [(0, 2), (2, 8), (8, 6), (6, 0), (1, 5), (5, 7), (7, 3), (3, 1), (9, 15), (15, 17), (17, 11), (11, 9), (10, 12), (12, 16), (16, 14), (14, 10), (20, 47), (19, 46), (18, 45), (47, 38), (46, 37), (45, 36), (38, 29), (37, 28), (36, 27), (29, 20), (28, 19), (27, 18), (23, 50), (22, 49), (21, 48), (50, 41), (49, 40), (48, 39), (41, 32), (40, 31), (39, 30), (32, 23), (31, 22), (30, 21), (26, 53), (25, 52), (24, 51), (53, 44), (52, 43), (51, 42), (41, 32), (43, 34), (44, 35), (42, 33), (35, 26), (34, 25), (33, 24)]) x = Move( cy([20, 2, 42, 11]) + cy([19, 1, 43, 10]) + cy([18, 0, 44, 9]) + cy([23, 5, 39, 14]) + cy([22, 4, 40, 13]) + cy( [21, 3, 41, 12]) + cy([27, 29, 35, 33]) + cy([28, 32, 34, 30]) + cy([45, 51, 53, 47]) + cy( [46, 48, 52, 50]) + cy([26, 8, 36, 17]) + cy([25, 7, 37, 16]) + cy([24, 6, 38, 15])) # Other moves out of the manually coded moves: # x move setup x2 = move_from_sequence([x, x]) x_ = x.inverted # R move setup R_ = R.inverted() R2 = move_from_sequence([R, R]) # y move setup y2 = move_from_sequence([y, y]) y_ = y.inverted() # L move setup L = move_from_sequence([y2, R, y2]) L_ = L.inverted() L2 = move_from_sequence([L, L]) # F move setup F = move_from_sequence([y_, R, y]) F2 = move_from_sequence([F, F]) F_ = F.inverted() # B move setup B = move_from_sequence([y, R, y_]) B_ = B.inverted() B2 = move_from_sequence([B, B]) # U move setup U = move_from_sequence([x_, y_, R, y, x]) # The code breaks down when I start using x moves, I don't know why. U_ = U.inverted() U2 = move_from_sequence([U, U]) # D move setup D = move_from_sequence([x2, U, x2]) D_ = D.inverted() D2 = move_from_sequence([D, D]) # M move setup M = move_from_sequence([R, L_, x_]) M_ = M.inverted() M2 = move_from_sequence([M, M]) z = move_from_sequence([x, y, x_]) z_ = z.inverted() z2 = move_from_sequence([z, z])
Code:Traceback (most recent call last): File "C:/Users/[Redacted cause it had my last name]/PycharmProjects/SalmonCube/SalmonCube.py", line 108, in <module> U = move_from_sequence([x_, y_, R, y, x]) # The code breaks down when I start using x moves, I don't know why. File "C:/Users/[Redacted]/PycharmProjects/SalmonCube/SalmonCube.py", line 42, in move_from_sequence cube.sequence(sequence) File "C:/Users/[Redacted]/PycharmProjects/SalmonCube/SalmonCube.py", line 30, in sequence self.move(move) File "C:/Users/[Redacted]/PycharmProjects/SalmonCube/SalmonCube.py", line 22, in move indices = move.indices AttributeError: 'function' object has no attribute 'indices'
Thats kind of whats confusing me. I'm inputting a move object, which does have the attribut indices, but its saying its a function.I dunno if I'm just being dumb, but it looks like Cube.move() has no attribute "indices"
Have you tried self.indices?Thats kind of whats confusing me. I'm inputting a move object, which does have the attribut indices, but its saying its a function.
It is in the cube class, which doest have an indices attribute so it wou ld just give an error.Have you tried self.indices?
Yay! There's away's that great feeling that's immediately crushed by the next bug...I solved it! I just commented out the code that broke it, and ran through my variables with print(type(variable)) to see what was causing the issue, and in my definition of x_ (I use underscores instead of apostrophes for inverse moves) I had it as
x_=x.inverted
Instead of x_=x.inverted()
So it was assigning the function itself to x_, instead of the inverted value of x.
Now I'm gonna actually test to see if the cube functions by going to the example solve game and inputting one of the scrambles and solutions from there to see if it succesfully solves it with that.
Ayy! When/how are you thinking of adding alg-genning?IT WORKED YAYAYAYYA!!!! I plugged a scramble into the thing, did it on my normal cube, and the top and bottom sides matched. I didn't check other but I'm quite sure they worked because when I plugged in WoowyBaby's FMC amazingness solution into it it solved it.
There are a lot of programs with alg genning, so I think I might focus on AI and stuff. Plus I don't like algs. But if i did do algs I think (Correct me if this totally wouldn't work) I might be able to make an object, which has one move stored in it, which then makes a number of child objects each with different moves, which each makes the same number more, and then each new object tests to see if its moves along with its parents and grandparents' moves solve the case, if not, it makes more child objects.Ayy! When/how are you thinking of adding alg-genning?
That seems like it would take a lot of CPU. Also, what do you mean by AI?There are a lot of programs with alg genning, so I think I might focus on AI and stuff. Plus I don't like algs. But if i did do algs I think (Correct me if this totally wouldn't work) I might be able to make an object, which has one move stored in it, which then makes a number of child objects each with different moves, which each makes the same number more, and then each new object tests to see if its moves along with its parents and grandparents' moves solve the case, if not, it makes more child objects.