1 |
9ba7f3f6
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2021 Leszek Koltunski //
|
3 |
|
|
// //
|
4 |
|
|
// This file is part of Magic Cube. //
|
5 |
|
|
// //
|
6 |
|
|
// Magic Cube is proprietary software licensed under an EULA which you should have received //
|
7 |
|
|
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html //
|
8 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
9 |
|
|
|
10 |
|
|
package org.distorted.objectlib.scrambling;
|
11 |
|
|
|
12 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
13 |
|
|
|
14 |
|
|
public class ScrambleEdgeGenerator
|
15 |
|
|
{
|
16 |
|
|
private static void insertSection(int[] table, int startIndex, int size, int startAlg, int state)
|
17 |
|
|
{
|
18 |
|
|
int num = size/2;
|
19 |
|
|
|
20 |
|
|
for(int i=0; i<num; i++)
|
21 |
|
|
{
|
22 |
|
|
table[2*(i+startIndex) ] = startAlg +i;
|
23 |
|
|
table[2*(i+startIndex)+1] = state;
|
24 |
|
|
}
|
25 |
|
|
}
|
26 |
|
|
|
27 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
28 |
|
|
|
29 |
|
|
private static int[] createEdge(int sizeX, int sizeY, int sizeZ, int stateX, int stateY, int stateZ)
|
30 |
|
|
{
|
31 |
|
|
int num = 0;
|
32 |
|
|
int consX = ((sizeY!=sizeZ) ? 2:6)*sizeX;
|
33 |
|
|
int consY = ((sizeX!=sizeZ) ? 2:6)*sizeY;
|
34 |
|
|
int consZ = ((sizeX!=sizeY) ? 2:6)*sizeZ;
|
35 |
|
|
if( stateX>=0 ) num += consX;
|
36 |
|
|
if( stateY>=0 ) num += consY;
|
37 |
|
|
if( stateZ>=0 ) num += consZ;
|
38 |
|
|
|
39 |
|
|
int[] ret = new int[num];
|
40 |
|
|
int index = 0;
|
41 |
|
|
int algor = 0;
|
42 |
|
|
if( stateX>=0 ) { insertSection(ret,index,consX,algor,stateX); index += consX/2; }
|
43 |
|
|
algor += consX/2;
|
44 |
|
|
if( stateY>=0 ) { insertSection(ret,index,consY,algor,stateY); index += consY/2; }
|
45 |
|
|
algor += consY/2;
|
46 |
|
|
if( stateZ>=0 ) { insertSection(ret,index,consZ,algor,stateZ); }
|
47 |
|
|
|
48 |
|
|
return ret;
|
49 |
|
|
}
|
50 |
|
|
|
51 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
52 |
|
|
|
53 |
|
|
public static int[][] getScrambleEdgesCuboid(int X, int Y, int Z)
|
54 |
|
|
{
|
55 |
|
|
return new int[][]
|
56 |
|
|
{
|
57 |
|
|
createEdge(X,Y,Z, 1, 2, 3), // 0 0
|
58 |
|
|
createEdge(X,Y,Z,-1, 4, 5), // 1 x
|
59 |
|
|
createEdge(X,Y,Z, 6,-1, 7), // 2 y
|
60 |
|
|
createEdge(X,Y,Z, 8, 9,-1), // 3 z
|
61 |
|
|
createEdge(X,Y,Z,10,-1, 7), // 4 xy
|
62 |
|
|
createEdge(X,Y,Z,11, 9,-1), // 5 xz
|
63 |
|
|
createEdge(X,Y,Z,-1,12, 5), // 6 yx
|
64 |
|
|
createEdge(X,Y,Z, 8,13,-1), // 7 yz
|
65 |
|
|
createEdge(X,Y,Z,-1, 4,14), // 8 zx
|
66 |
|
|
createEdge(X,Y,Z, 6,-1,15), // 9 zy
|
67 |
|
|
createEdge(X,Y,Z,-1,-1, 5), // 10 xyx
|
68 |
|
|
createEdge(X,Y,Z,-1, 4,-1), // 11 xzx
|
69 |
|
|
createEdge(X,Y,Z,-1,-1, 7), // 12 yxy
|
70 |
|
|
createEdge(X,Y,Z, 6,-1,-1), // 13 yzy
|
71 |
|
|
createEdge(X,Y,Z,-1, 9,-1), // 14 zxz
|
72 |
|
|
createEdge(X,Y,Z, 8,-1,-1), // 15 zyz
|
73 |
|
|
};
|
74 |
|
|
}
|
75 |
|
|
|
76 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
77 |
|
|
|
78 |
|
|
public static int[][] getScrambleEdgesSingle(int[][] basicAngle)
|
79 |
|
|
{
|
80 |
|
|
int size=0;
|
81 |
|
|
|
82 |
|
|
for (int[] basic : basicAngle)
|
83 |
|
|
for (int i : basic) size += (i-1);
|
84 |
|
|
|
85 |
|
|
int[] edge = new int[2*size];
|
86 |
|
|
for(int i=0; i<size; i++)
|
87 |
|
|
{
|
88 |
|
|
edge[2*i ] = i;
|
89 |
|
|
edge[2*i+1] = 0;
|
90 |
|
|
}
|
91 |
|
|
|
92 |
|
|
return new int[][] { edge };
|
93 |
|
|
}
|
94 |
731280f7
|
Leszek Koltunski
|
|
95 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
96 |
|
|
|
97 |
|
|
public static int[][] getScramblingAlgorithms(int[][] basicAngles)
|
98 |
|
|
{
|
99 |
|
|
int numAxis= basicAngles.length;
|
100 |
|
|
int num=0;
|
101 |
|
|
|
102 |
|
|
for (int[] basic : basicAngles)
|
103 |
|
|
for (int i : basic) num += (i-1);
|
104 |
|
|
|
105 |
|
|
int[][] ret = new int[num][3];
|
106 |
|
|
int index = 0;
|
107 |
|
|
|
108 |
|
|
for(int i=0; i<numAxis; i++)
|
109 |
|
|
{
|
110 |
|
|
int numLayers = basicAngles[i].length;
|
111 |
|
|
|
112 |
|
|
for(int j=0; j<numLayers; j++)
|
113 |
|
|
{
|
114 |
|
|
int N = basicAngles[i][j];
|
115 |
|
|
int NEG = (1-N)/2;
|
116 |
|
|
int POS = N/2;
|
117 |
|
|
|
118 |
|
|
for(int k=NEG; k<=-1; k++)
|
119 |
|
|
{
|
120 |
|
|
ret[index][0] = i;
|
121 |
|
|
ret[index][1] = j;
|
122 |
|
|
ret[index][2] = k;
|
123 |
|
|
index++;
|
124 |
|
|
}
|
125 |
|
|
|
126 |
|
|
for(int k=1; k<=POS; k++)
|
127 |
|
|
{
|
128 |
|
|
ret[index][0] = i;
|
129 |
|
|
ret[index][1] = j;
|
130 |
|
|
ret[index][2] = k;
|
131 |
|
|
index++;
|
132 |
|
|
}
|
133 |
|
|
}
|
134 |
|
|
}
|
135 |
|
|
|
136 |
|
|
return ret;
|
137 |
|
|
}
|
138 |
9ba7f3f6
|
Leszek Koltunski
|
}
|