You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have need of an array representation of the cube, either as a flat array or an array of six arrays for each face. I haven't found anything existing to do this, so I've come up with my own hacky method, but this feels like something that should be part of the Cube class. Here's what I did:
def cubeAsArray(cube):
faces = ["L", "R", "U", "D", "B", "F"]
cubeArray = []
for face in faces:
face = cube.get_face(face) # get face, iterate over all squares.
for x in [0,1,2]:
for y in [0,1,2]:
cubeArray.append(str(face[x][y]))
return cubeArray
The text was updated successfully, but these errors were encountered:
Hi @PAK90, although this kind of usage might be useful, I wouldn't consider this "should be" a part of the Cube class, because the design of Cube class is to use "cubie" as component of the cube instead of six faces. Though if you'd like to contribute to this project, you can add this function into pycuber/helpers.py and submit a pull request!
Hi, here is a function I use to convert a cube to an ndarray, this is especially useful for ML applications
def cube2np(mycube):
# transform cube object to np array
# works around the weird data type used
global faces
global colors
cube_np = np.zeros((6,3,3))
for i,face in enumerate(faces):
face_tmp = mycube.get_face(face)
for j in range(3):
for k in range(len(face_tmp[j])):
caca = face_tmp[j][k]
cube_np[i,j,k] = colors.index(str(caca))
return cube_np
I have need of an array representation of the cube, either as a flat array or an array of six arrays for each face. I haven't found anything existing to do this, so I've come up with my own hacky method, but this feels like something that should be part of the Cube class. Here's what I did:
The text was updated successfully, but these errors were encountered: