## ## ## skewb.mpl ## simulates the moves of the Rubikized octahedron ## ## David Joyner, 1996 ########################################################### A0:=array([[1,1,1,1,1],[2,2,2,2,2],[3,3,3,3,3], [4,4,4,4,4],[5,5,5,5,5],[6,6,6,6,6]]); #basic moves FRU:= [[6, 16, 21],[7, 18, 25],[10, 17, 24],[8, 19, 22]]: BRU:= [[21, 16, 26],[22, 17, 30],[25, 20, 29],[23, 18, 27]]: BLU:= [[26 ,16, 1],[27, 20, 5],[28, 17, 2],[30, 19, 4]]: FLU:= [[1, 16, 6],[2, 19, 10],[5, 18, 9],[3, 20, 7]]: DFR:= [[11, 6, 21],[25, 13, 9],[23, 15, 7],[24, 12, 8]]: BDR:= [[26, 11, 21],[29, 13, 23],[27, 12, 22],[30, 14, 24]]: DFL:= [[6, 11, 1],[9, 15, 3],[10, 12, 4],[8, 14, 2]]: BDL:= [[1, 11, 26],[3, 13, 27],[4, 14, 28],[5, 15, 29]]: slr:= [[6, 16, 26, 11],[7, 17, 29, 12],[10, 20, 28, 15], [9,19,27,14],[8,18,30,13],[22,23,24,25],[2,5,4,3]]: sbf:=[[21,16,1,11],[22,20,4,13],[23,17,5,14],[24,18,2,15], [25,19,3,12],[7,10,9,8],[30,27,28,29]]: color1 := red: color2 := blue: color3 := coral: color4 := plum: color5 := green: color6 := yellow: skewb_squares := proc () local i; for i from 1 to 3 do F1.i:=[3,-3+3*(i-1),3]; #i=1,2,3 F3.i:=[3,-3+3*(i-1),-3]; #i=1,2,3 R1.i:=[-3+3*(i-1),3,3]; #i=1,2,3 R3.i:=[-3+3*(i-1),3,-3]; #i=1,2,3 B1.i:=[-3,-3+3*(i-1),3]; B3.i:=[-3,-3+3*(i-1),-3]; L1.i:=[-3+3*(i-1),-3,3]; L3.i:=[-3+3*(i-1),-3,-3]; U1.i:=[-3+3*(i-1),3,3]; U3.i:=[-3+3*(i-1),-3,3]; D1.i:=[-3+3*(i-1),3,-3]; D3.i:=[-3+3*(i-1),-3,-3]; od; for i from 1 to 2 do F2.i:=[3,-3+6*(i-1),0]; #i=1,2 R2.i:=[-3+6*(i-1),3,0]; #i=1,2 B2.i:=[-3,-3+6*(i-1),0]; L2.i:=[-3+6*(i-1),-3,0]; U2.i:=[-3+6*(i-1),0,3]; D2.i:=[-3+6*(i-1),0,-3]; od; end: skewb_draw := proc (A::array) local i, j, face_F0,face_F1,face_F2,face_F3,face_F4, face_B0,face_B1,face_B2,face_B3,face_B4, face_L0,face_L1,face_L2,face_L3,face_L4, face_R0,face_R1,face_R2,face_R3,face_R4, face_U0,face_U1,face_U2,face_U3,face_U4, face_D0,face_D1,face_D2,face_D3,face_D4, L; skewb_squares(); face_F0:=polygonplot3d([F12,F22,F32,F21],style=patch, color=color.(A[1,1])); #square face_F1:=polygonplot3d([F22,F33,F32],style=patch, color=color.(A[1,2])); face_F2:=polygonplot3d([F12,F13,F22],style=patch, color=color.(A[1,3])); face_F3:=polygonplot3d([F11,F12,F21],style=patch, color=color.(A[1,4])); face_F4:=polygonplot3d([F21,F32,F31],style=patch, color=color.(A[1,5])); face_B0:=polygonplot3d([B12,B22,B32,B21],style=patch, color=color.(A[2,1])); #square face_B1:=polygonplot3d([B22,B33,B32],style=patch, color=color.(A[2,2])); face_B2:=polygonplot3d([B12,B13,B22],style=patch, color=color.(A[2,3])); face_B3:=polygonplot3d([B11,B12,B21],style=patch, color=color.(A[2,4])); face_B4:=polygonplot3d([B21,B32,B31],style=patch, color=color.(A[2,5])); face_U0:=polygonplot3d([U12,U22,U32,U21],style=patch, color=color.(A[3,1])); #square face_U1:=polygonplot3d([U22,U33,U32],style=patch, color=color.(A[3,2])); face_U2:=polygonplot3d([U12,U13,U22],style=patch, color=color.(A[3,3])); face_U3:=polygonplot3d([U11,U12,U21],style=patch, color=color.(A[3,4])); face_U4:=polygonplot3d([U21,U32,U31],style=patch, color=color.(A[3,5])); face_D0:=polygonplot3d([D12,D22,D32,D21],style=patch, color=color.(A[4,1])); #square face_D1:=polygonplot3d([D22,D33,D32],style=patch, color=color.(A[4,2])); face_D2:=polygonplot3d([D12,D13,D22],style=patch, color=color.(A[4,3])); face_D3:=polygonplot3d([D11,D12,D21],style=patch, color=color.(A[4,4])); face_D4:=polygonplot3d([D21,D32,D31],style=patch, color=color.(A[4,5])); face_R0:=polygonplot3d([R12,R22,R32,R21],style=patch, color=color.(A[5,1])); #square face_R1:=polygonplot3d([R22,R33,R32],style=patch, color=color.(A[5,2])); face_R2:=polygonplot3d([R12,R13,R22],style=patch, color=color.(A[5,3])); face_R3:=polygonplot3d([R11,R12,R21],style=patch, color=color.(A[5,4])); face_R4:=polygonplot3d([R21,R32,R31],style=patch, color=color.(A[5,5])); face_L0:=polygonplot3d([L12,L22,L32,L21],style=patch, color=color.(A[6,1])); #square face_L1:=polygonplot3d([L22,L33,L32],style=patch, color=color.(A[6,2])); face_L2:=polygonplot3d([L12,L13,L22],style=patch, color=color.(A[6,3])); face_L3:=polygonplot3d([L11,L12,L21],style=patch, color=color.(A[6,4])); face_L4:=polygonplot3d([L21,L32,L31],style=patch, color=color.(A[6,5])); L:= [face_F0,face_F1,face_F2,face_F3,face_F4, face_B0,face_B1,face_B2,face_B3,face_B4, face_L0,face_L1,face_L2,face_L3,face_L4, face_R0,face_R1,face_R2,face_R3,face_R4, face_U0,face_U1,face_U2,face_U3,face_U4, face_D0,face_D1,face_D2,face_D3,face_D4]; RETURN(L) end: ##skewb move notes #the move FRU fru:=proc(A::array) local Anew,i,j; Anew:=array(1..6,1..5); for i from 1 to 6 do for j from 1 to 5 do Anew[i,j]:=A[i,j]; od; od; Anew[3,1]:= A[1,1]; #A[1,1] is sent to A[3,1] Anew[3,2]:= A[1,2]; Anew[3,3]:= A[1,3]; Anew[3,4]:= A[1,4]; Anew[1,1]:= A[5,1]; Anew[1,2]:= A[5,4]; Anew[1,3]:= A[5,3]; Anew[1,4]:= A[5,2]; Anew[5,1]:= A[3,1]; Anew[5,2]:= A[3,4]; Anew[5,3]:= A[3,3]; Anew[5,4]:= A[3,2]; Anew[6,3]:=A[4,3]; Anew[2,3]:=A[6,3]; Anew[4,3]:=A[2,3]; #FUR affects no other pieces RETURN(Anew); end: #the move FLU flu:=proc(A::array) local Anew,i,j; Anew:=array(1..6,1..5); for i from 1 to 6 do for j from 1 to 5 do Anew[i,j]:=A[i,j]; od; od; Anew[6,3]:= A[1,4]; Anew[1,4]:= A[3,2]; Anew[3,2]:= A[6,3]; Anew[1,1]:= A[3,1]; Anew[3,1]:= A[6,1]; Anew[6,1]:= A[1,1]; Anew[1,3]:= A[3,5]; Anew[3,5]:= A[6,2]; Anew[6,2]:= A[1,3]; Anew[1,3]:= A[3,5]; Anew[3,5]:= A[6,2]; Anew[6,2]:= A[1,3]; Anew[1,5]:= A[3,3]; Anew[3,3]:= A[6,4]; Anew[6,4]:= A[1,5]; Anew[4,2]:= A[5,3]; Anew[5,3]:= A[2,4]; Anew[2,4]:= A[4,2]; #LUF affects no other pieces RETURN(Anew); end: #Slr denotes the "spin" of the cube about the R-L axis slr:=proc(A::array) local Anew,i,j; Anew:=array(1..6,1..5); for i from 1 to 6 do for j from 1 to 5 do Anew[i,j]:=A[i,j]; od; od; Anew[3,1]:= A[1,1]; Anew[1,1]:= A[4,1]; Anew[4,1]:= A[2,1]; Anew[2,1]:= A[3,1]; Anew[3,4]:= A[1,3]; Anew[1,3]:= A[4,3]; Anew[4,3]:= A[2,2]; Anew[2,2]:= A[3,4]; Anew[3,3]:= A[1,2]; Anew[1,2]:= A[4,4]; Anew[4,4]:= A[2,3]; Anew[2,3]:= A[3,3]; Anew[3,2]:= A[1,5]; Anew[1,5]:= A[4,5]; Anew[4,5]:= A[2,4]; Anew[2,4]:= A[3,2]; Anew[3,5]:= A[1,4]; Anew[1,4]:= A[4,2]; Anew[4,2]:= A[2,5]; Anew[2,5]:= A[3,5]; Anew[5,3]:= A[5,2]; Anew[5,2]:= A[5,5]; Anew[5,5]:= A[5,4]; Anew[5,4]:= A[5,3]; Anew[6,3]:= A[6,2]; Anew[6,2]:= A[6,5]; Anew[6,5]:= A[6,4]; Anew[6,4]:= A[6,3]; #srl affects no other pieces RETURN(Anew); end: dfr:=proc(A::array) local Anew,i,j; Anew:=slr(slr(slr(fru(slr(A))))); RETURN(Anew); end: dfl:=proc(A::array) local Anew,i,j; Anew:=slr(slr(slr(flu(slr(A))))); RETURN(Anew); end: bru:=proc(A::array) local Anew,i,j; Anew:=slr(fru(slr(slr(slr(A))))); RETURN(Anew); end: bdr:=proc(A::array) local Anew,i,j; Anew:=slr(slr(fru(slr(slr(A))))); RETURN(Anew); end: blu:=proc(A::array) local Anew,i,j; Anew:=slr(flu(slr(slr(slr(A))))); RETURN(Anew); end: bdl:=proc(A::array) local Anew,i,j; Anew:=slr(slr(flu(slr(slr(A))))); RETURN(Anew); end: move_power:=proc(g,A::array) local i,j,AA,generators,gen,power; generators:={FRU,FLU,BRU,BLU,BDR,BDL,DFR,DFL}; AA:=A; if type(g,`^`) then gen:=op(1,g); power:=op(2,g) mod 3; else if member(g,generators) then gen:=g; power:=1; fi; fi; if g=1 then RETURN(A); fi; for i from 1 to power do if gen=FRU then AA:=fru(A) fi; if gen=FLU then AA:=flu(A) fi; if gen=BRU then AA:=bru(A) fi; if gen=BLU then AA:=blu(A) fi; if gen=BDR then AA:=bdr(A) fi; if gen=BDL then AA:=bdl(A) fi; if gen=DFR then AA:=dfr(A) fi; if gen=DFL then AA:=dfl(A) fi; od; RETURN(AA); end: move:=proc(w,A) local i,AA,generators; generators:={FRU,FLU,BRU,BLU,BDR,BDL,DFR,DFL}; AA:=A; if type(w,`^`) then AA:=move_power(w,AA); fi; if w=1 then RETURN(AA); fi; if member(w,generators) then AA:=move_power(w,AA); fi; if type(w,list) then for i from 1 to nops(w) do AA:=move_power(op(i,w),AA); od; fi; RETURN(AA); end: rs := proc (L, A) local AA, LL; AA := move(L,A); LL := skewb_draw(AA); display3d(LL) end: help_skewb:=proc() print(`Moves are generated by FRU,FLU,BRU,BLU,BDR,BDL,DFR,DFL`); print(`type "rs(1,A0);" to see the solved skewb and, for example,`); print(`"rs([FRU,FRU,BRU],A0);" to see the move FRU^(-1)*BRU.`); end: