public Cube(byte[] faceletColors) { corners = new Cubie[8]; edges = new Cubie[12]; byte[] tuple, cubie; int i, o, val; for (i = 0; i < 8; i++) { tuple = CornerFacelet[i]; cubie = tuple.Select(x => faceletColors[x]).ToArray(); val = CornerMap.Index(cubie, Tools.setEquals); o = cubie.Index(CornerMap[val][0]); corners[i] = new Cubie((byte)val, (byte)o); } for (i = 0; i < 12; i++) { tuple = EdgeFacelet[i]; cubie = tuple.Select(x => faceletColors[x]).ToArray(); val = EdgeMap.Index(cubie, Tools.setEquals); o = cubie.Index(EdgeMap[val][0]); edges[i] = new Cubie((byte)val, (byte)o); } }
public byte[] getFacelets() { byte[] facelets = new byte[48]; int i, j; for (i = 0; i < 8; i++) { Cubie c = corners[i]; var ct = CornerFacelet[c.pos].rotate(c.orient); for (j = 0; j < 3; j++) { facelets[CornerFacelet[i][j]] = ct[j]; } } for (i = 0; i < 12; i++) { Cubie e = edges[i]; var et = EdgeFacelet[e.pos].rotate(e.orient); for (j = 0; j < 2; j++) { facelets[EdgeFacelet[i][j]] = et[j]; } } return(facelets); }
public static Cube apply(Cube cube, byte move, byte ap = 3) { int ax = move / 3; int po = move % 3; int x, i; Cubie c; Cubie[] edges, corns; for (x = 0; x <= po; x++) { corns = new Cubie[8]; edges = new Cubie[12]; if ((ap & 2) == 2) { for (i = 0; i < 8; i++) { c = cube.corners[cornMoveTable[ax, i, 0]]; corns[i] = new Cubie( c.pos, (byte)((cornMoveTable[ax, i, 1] + c.orient) % 3) ); } } else { corns = cube.corners; } if ((ap & 1) == 1) { for (i = 0; i < 12; i++) { c = cube.edges[edgeMoveTable[ax, i, 0]]; edges[i] = new Cubie( c.pos, (byte)((edgeMoveTable[ax, i, 1] + c.orient) % 2) ); } } else { edges = cube.edges; } cube = new Cube(corns, edges); } return(cube); }