50 |
50 |
return ret;
|
51 |
51 |
}
|
52 |
52 |
|
|
53 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
54 |
|
|
55 |
private static int getRowBmp(int val, int[] counters)
|
|
56 |
{
|
|
57 |
int bmp = 0;
|
|
58 |
int len = counters.length;
|
|
59 |
|
|
60 |
for(int i=0; i<len; i++)
|
|
61 |
if( counters[i]==val ) bmp += (1<<i);
|
|
62 |
|
|
63 |
return bmp;
|
|
64 |
}
|
|
65 |
|
|
66 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
67 |
|
|
68 |
private static int getNumInitGhostMoves(int[] rowState, int[] counters)
|
|
69 |
{
|
|
70 |
int len = (rowState!=null ? rowState.length : 0);
|
|
71 |
for(int i=0; i<len; i++) counters[i] = -1;
|
|
72 |
int numDifferentRowStates = 0;
|
|
73 |
boolean thereIsZero = false;
|
|
74 |
|
|
75 |
for(int i=0; i<len; i++)
|
|
76 |
if( counters[i]<0 )
|
|
77 |
{
|
|
78 |
int v = rowState[i];
|
|
79 |
if( v==0 ) thereIsZero = true;
|
|
80 |
counters[i] = numDifferentRowStates++;
|
|
81 |
|
|
82 |
for(int j=i+1; j<len; j++)
|
|
83 |
if( rowState[j]==v ) counters[j] = counters[i];
|
|
84 |
}
|
|
85 |
|
|
86 |
int nonZero = numDifferentRowStates;
|
|
87 |
if( thereIsZero ) nonZero--;
|
|
88 |
|
|
89 |
return nonZero;
|
|
90 |
}
|
|
91 |
|
|
92 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
93 |
// rowState contains initial rotations of individual ghostLayers (in multiples of ghostAngle)
|
|
94 |
// We need to first count how many different non-zero rotations there are, and then return this
|
|
95 |
// many ObjectMoves so that after having made them the Ghost gets unblocked.
|
|
96 |
|
|
97 |
private static ObjectMove[][] getInitGhostMoves(int[] rowState, int basicAngle, int ghostAngle)
|
|
98 |
{
|
|
99 |
if( rowState!=null )
|
|
100 |
{
|
|
101 |
int basicNum = 360/basicAngle;
|
|
102 |
int len = rowState.length;
|
|
103 |
int[] counters = new int[len];
|
|
104 |
int nonZero = getNumInitGhostMoves(rowState,counters);
|
|
105 |
int numDifferentRowStates = nonZero;
|
|
106 |
|
|
107 |
for(int r : rowState)
|
|
108 |
if( r==0 )
|
|
109 |
{
|
|
110 |
numDifferentRowStates++;
|
|
111 |
break;
|
|
112 |
}
|
|
113 |
|
|
114 |
ObjectMove[][] ret = new ObjectMove[basicNum*nonZero][];
|
|
115 |
int index1=0, index2=0;
|
|
116 |
|
|
117 |
for(int i=0; i<numDifferentRowStates; i++)
|
|
118 |
{
|
|
119 |
for( ;index1<len; index1++)
|
|
120 |
if( counters[index1]==i ) break;
|
|
121 |
|
|
122 |
int mult = rowState[index1];
|
|
123 |
|
|
124 |
if( mult!=0 )
|
|
125 |
{
|
|
126 |
int rowBmp = getRowBmp(counters[index1],counters);
|
|
127 |
|
|
128 |
for(int b=0; b<basicNum; b++)
|
|
129 |
ret[index2++][0] = new ObjectMove(ghostAngle,rowBmp,b*basicAngle + mult*ghostAngle);
|
|
130 |
}
|
|
131 |
}
|
|
132 |
|
|
133 |
return ret;
|
|
134 |
}
|
|
135 |
|
|
136 |
return null;
|
|
137 |
}
|
|
138 |
|
53 |
139 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
54 |
140 |
|
55 |
141 |
public static int[][] getScrambleEdgesCuboid(int X, int Y, int Z)
|
... | ... | |
123 |
209 |
|
124 |
210 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
125 |
211 |
|
126 |
|
public static int[][] getScrambleEdgesGhost(int[][] basicAngles, int ghostAxis)
|
|
212 |
public static int[][] getScrambleEdgesGhost(int[][] basicAngles, int ghostAxis, int[] rowState)
|
127 |
213 |
{
|
|
214 |
int[] counters = (rowState!=null ? new int[rowState.length] : null);
|
|
215 |
int nonZero = getNumInitGhostMoves(rowState,counters);
|
128 |
216 |
int sizeGhost = basicAngles[ghostAxis][0];
|
129 |
|
int sizeNonGhost = 0;
|
130 |
|
|
131 |
|
for (int[] basic : basicAngles)
|
132 |
|
for (int i : basic) sizeNonGhost += (i-1);
|
133 |
217 |
|
|
218 |
// TODO
|
134 |
219 |
int[] edge0 = new int[2*sizeGhost];
|
135 |
220 |
|
136 |
221 |
for( int m=0; m<sizeGhost; m++ )
|
... | ... | |
139 |
224 |
edge0[2*m+1] = 1;
|
140 |
225 |
}
|
141 |
226 |
|
|
227 |
int sizeNonGhost = 0;
|
|
228 |
for (int[] basic : basicAngles)
|
|
229 |
for (int i : basic) sizeNonGhost += (i-1);
|
|
230 |
|
142 |
231 |
int[] edge1 = new int[2*sizeNonGhost];
|
143 |
232 |
|
144 |
233 |
for( int m=0; m<sizeNonGhost; m++ )
|
... | ... | |
228 |
317 |
|
229 |
318 |
public static ObjectMove[][] getGhostScramblingAlgorithms(int[][] basicAngles, int ghostAxis, int[] rowState, int ghostAngle)
|
230 |
319 |
{
|
231 |
|
int sizeGhost = basicAngles[ghostAxis][0];
|
232 |
|
int half = sizeGhost/2;
|
233 |
|
int ghostRowBitmap = (1<<ghostRow)-1;
|
234 |
|
ObjectMove[][] tmp = getScramblingAlgorithms(basicAngles);
|
235 |
|
int len = tmp.length;
|
236 |
|
ObjectMove[][] moves = new ObjectMove[sizeGhost+len][1];
|
237 |
|
|
238 |
|
for(int m=0; m<sizeGhost; m++) moves[m][0] = new ObjectMove(ghostAxis, ghostRowBitmap, (m-half)*360/sizeGhost+ghostAngle);
|
239 |
|
for(int m=0; m<len; m++) moves[m+sizeGhost][0] = tmp[m][0];
|
|
320 |
ObjectMove[][] tmp1 = getInitGhostMoves(rowState,basicAngles[ghostAxis][0],ghostAngle);
|
|
321 |
ObjectMove[][] tmp2 = getScramblingAlgorithms(basicAngles);
|
|
322 |
int len1 = (tmp1!=null ? tmp1.length : 0);
|
|
323 |
int len2 = tmp2.length;
|
|
324 |
ObjectMove[][] moves = new ObjectMove[len1+len2][1];
|
|
325 |
|
|
326 |
if( tmp1!=null ) System.arraycopy(tmp1,0,moves,0,len1);
|
|
327 |
System.arraycopy(tmp2,0,moves,len1,len2);
|
240 |
328 |
|
241 |
329 |
return moves;
|
242 |
330 |
}
|
progress with GhostCubes