1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2020 Leszek Koltunski //
|
3
|
// //
|
4
|
// This file is part of Magic Cube. //
|
5
|
// //
|
6
|
// Magic Cube is free software: you can redistribute it and/or modify //
|
7
|
// it under the terms of the GNU General Public License as published by //
|
8
|
// the Free Software Foundation, either version 2 of the License, or //
|
9
|
// (at your option) any later version. //
|
10
|
// //
|
11
|
// Magic Cube is distributed in the hope that it will be useful, //
|
12
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
13
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
14
|
// GNU General Public License for more details. //
|
15
|
// //
|
16
|
// You should have received a copy of the GNU General Public License //
|
17
|
// along with Magic Cube. If not, see <http://www.gnu.org/licenses/>. //
|
18
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19
|
|
20
|
package org.distorted.objects;
|
21
|
|
22
|
import android.content.res.Resources;
|
23
|
|
24
|
import org.distorted.helpers.ScrambleState;
|
25
|
import org.distorted.library.main.DistortedEffects;
|
26
|
import org.distorted.library.main.DistortedTexture;
|
27
|
import org.distorted.library.mesh.MeshSquare;
|
28
|
import org.distorted.library.type.Static3D;
|
29
|
import org.distorted.library.type.Static4D;
|
30
|
|
31
|
import java.util.Random;
|
32
|
|
33
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
34
|
|
35
|
abstract class TwistyMinx extends TwistyObject
|
36
|
{
|
37
|
private static final int FACES_PER_CUBIT =6;
|
38
|
|
39
|
static final int NUM_CORNERS = 20;
|
40
|
static final int NUM_CENTERS = 12;
|
41
|
static final int NUM_EDGES = 30;
|
42
|
|
43
|
static final float C2 = (SQ5+3)/4;
|
44
|
static final float LEN = (float)(Math.sqrt(1.25f+0.5f*SQ5));
|
45
|
static final float SIN54 = (SQ5+1)/4;
|
46
|
static final float COS54 = (float)(Math.sqrt(10-2*SQ5)/4);
|
47
|
static final float SIN18 = (SQ5-1)/4;
|
48
|
static final float COS18 = (float)(0.25f*Math.sqrt(10.0f+2.0f*SQ5));
|
49
|
static final float COS_HALFD= (float)(Math.sqrt(0.5f-0.1f*SQ5)); // cos(half the dihedral angle)
|
50
|
static final float SIN_HALFD= (float)(Math.sqrt(0.5f+0.1f*SQ5)); // sin(half the dihedral angle)
|
51
|
|
52
|
// the six rotation axis of a Minx. Must be normalized.
|
53
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
54
|
{
|
55
|
new Static3D( C2/LEN, SIN54/LEN, 0 ),
|
56
|
new Static3D( -C2/LEN, SIN54/LEN, 0 ),
|
57
|
new Static3D( 0 , C2/LEN, SIN54/LEN ),
|
58
|
new Static3D( 0 , -C2/LEN, SIN54/LEN ),
|
59
|
new Static3D( SIN54/LEN, 0 , C2/LEN ),
|
60
|
new Static3D( SIN54/LEN, 0 , -C2/LEN )
|
61
|
};
|
62
|
|
63
|
private static final int[] BASIC_ANGLE = new int[] { 5,5,5,5,5,5 };
|
64
|
|
65
|
static final int MINX_LGREEN = 0xff53aa00;
|
66
|
static final int MINX_PINK = 0xfffd7ab7;
|
67
|
static final int MINX_SANDY = 0xffefd48b;
|
68
|
static final int MINX_LBLUE = 0xff00a2d7;
|
69
|
static final int MINX_ORANGE = 0xffff6200;
|
70
|
static final int MINX_VIOLET = 0xff7d59a4;
|
71
|
static final int MINX_DGREEN = 0xff007a47;
|
72
|
static final int MINX_DRED = 0xffbd0000;
|
73
|
static final int MINX_DBLUE = 0xff1a29b2;
|
74
|
static final int MINX_DYELLOW= 0xffffc400;
|
75
|
static final int MINX_WHITE = 0xffffffff;
|
76
|
static final int MINX_GREY = 0xff727c7b;
|
77
|
|
78
|
static final int[] FACE_COLORS = new int[]
|
79
|
{
|
80
|
MINX_LGREEN, MINX_PINK , MINX_SANDY , MINX_LBLUE,
|
81
|
MINX_ORANGE, MINX_VIOLET , MINX_DGREEN, MINX_DRED ,
|
82
|
MINX_DBLUE , MINX_DYELLOW, MINX_WHITE , MINX_GREY
|
83
|
};
|
84
|
|
85
|
private static final int[] mFaceMap = new int[] {8,10,3,7,1,11,9,2,4,0,5,6};
|
86
|
|
87
|
// All 60 legal rotation quats of a Minx
|
88
|
static final Static4D[] QUATS = new Static4D[]
|
89
|
{
|
90
|
new Static4D( 0.0f, 0.0f, 0.0f, 1.0f ), //0
|
91
|
new Static4D( 1.0f, 0.0f, 0.0f, 0.0f ),
|
92
|
new Static4D( 0.0f, 1.0f, 0.0f, 0.0f ),
|
93
|
new Static4D( 0.0f, 0.0f, 1.0f, 0.0f ),
|
94
|
|
95
|
new Static4D( 0.5f, 0.5f, 0.5f, 0.5f ), //4
|
96
|
new Static4D( 0.5f, 0.5f, -0.5f, 0.5f ),
|
97
|
new Static4D( 0.5f, -0.5f, 0.5f, 0.5f ),
|
98
|
new Static4D( 0.5f, -0.5f, -0.5f, 0.5f ),
|
99
|
new Static4D( -0.5f, 0.5f, 0.5f, 0.5f ),
|
100
|
new Static4D( -0.5f, 0.5f, -0.5f, 0.5f ),
|
101
|
new Static4D( -0.5f, -0.5f, 0.5f, 0.5f ),
|
102
|
new Static4D( -0.5f, -0.5f, -0.5f, 0.5f ),
|
103
|
|
104
|
new Static4D( 0.5f, SIN54, SIN18, 0.0f ), // 12
|
105
|
new Static4D( 0.5f, SIN54,-SIN18, 0.0f ),
|
106
|
new Static4D( 0.5f,-SIN54, SIN18, 0.0f ),
|
107
|
new Static4D( 0.5f,-SIN54,-SIN18, 0.0f ),
|
108
|
new Static4D( SIN18, 0.5f, SIN54, 0.0f ),
|
109
|
new Static4D( SIN18, 0.5f,-SIN54, 0.0f ),
|
110
|
new Static4D(-SIN18, 0.5f, SIN54, 0.0f ),
|
111
|
new Static4D(-SIN18, 0.5f,-SIN54, 0.0f ),
|
112
|
new Static4D( SIN54, SIN18, 0.5f, 0.0f ),
|
113
|
new Static4D( SIN54,-SIN18, 0.5f, 0.0f ),
|
114
|
new Static4D(-SIN54, SIN18, 0.5f, 0.0f ),
|
115
|
new Static4D(-SIN54,-SIN18, 0.5f, 0.0f ),
|
116
|
|
117
|
new Static4D( 0.0f, SIN18, SIN54, 0.5f ), //24
|
118
|
new Static4D( 0.0f, SIN18,-SIN54, 0.5f ),
|
119
|
new Static4D( 0.0f,-SIN18, SIN54, 0.5f ),
|
120
|
new Static4D( 0.0f,-SIN18,-SIN54, 0.5f ),
|
121
|
new Static4D( SIN18, SIN54, 0.0f, 0.5f ),
|
122
|
new Static4D( SIN18,-SIN54, 0.0f, 0.5f ),
|
123
|
new Static4D(-SIN18, SIN54, 0.0f, 0.5f ),
|
124
|
new Static4D(-SIN18,-SIN54, 0.0f, 0.5f ),
|
125
|
new Static4D( SIN54, 0.0f, SIN18, 0.5f ),
|
126
|
new Static4D( SIN54, 0.0f,-SIN18, 0.5f ),
|
127
|
new Static4D(-SIN54, 0.0f, SIN18, 0.5f ),
|
128
|
new Static4D(-SIN54, 0.0f,-SIN18, 0.5f ),
|
129
|
|
130
|
new Static4D( 0.0f, SIN54, 0.5f, SIN18 ), //36
|
131
|
new Static4D( 0.0f, SIN54, -0.5f, SIN18 ),
|
132
|
new Static4D( 0.0f,-SIN54, 0.5f, SIN18 ),
|
133
|
new Static4D( 0.0f,-SIN54, -0.5f, SIN18 ),
|
134
|
new Static4D( 0.5f, 0.0f, SIN54, SIN18 ),
|
135
|
new Static4D( 0.5f, 0.0f,-SIN54, SIN18 ),
|
136
|
new Static4D( -0.5f, 0.0f, SIN54, SIN18 ),
|
137
|
new Static4D( -0.5f, 0.0f,-SIN54, SIN18 ),
|
138
|
new Static4D( SIN54, 0.5f, 0.0f, SIN18 ),
|
139
|
new Static4D( SIN54, -0.5f, 0.0f, SIN18 ),
|
140
|
new Static4D(-SIN54, 0.5f, 0.0f, SIN18 ),
|
141
|
new Static4D(-SIN54, -0.5f, 0.0f, SIN18 ),
|
142
|
|
143
|
new Static4D( 0.0f, 0.5f, SIN18, SIN54 ), //48
|
144
|
new Static4D( 0.0f, 0.5f,-SIN18, SIN54 ),
|
145
|
new Static4D( 0.0f, -0.5f, SIN18, SIN54 ),
|
146
|
new Static4D( 0.0f, -0.5f,-SIN18, SIN54 ),
|
147
|
new Static4D( 0.5f, SIN18, 0.0f, SIN54 ),
|
148
|
new Static4D( 0.5f,-SIN18, 0.0f, SIN54 ),
|
149
|
new Static4D( -0.5f, SIN18, 0.0f, SIN54 ),
|
150
|
new Static4D( -0.5f,-SIN18, 0.0f, SIN54 ),
|
151
|
new Static4D( SIN18, 0.0f, 0.5f, SIN54 ),
|
152
|
new Static4D( SIN18, 0.0f, -0.5f, SIN54 ),
|
153
|
new Static4D(-SIN18, 0.0f, 0.5f, SIN54 ),
|
154
|
new Static4D(-SIN18, 0.0f, -0.5f, SIN54 ),
|
155
|
};
|
156
|
|
157
|
// Coordinates of all 20 corners of a Minx
|
158
|
static final float[][] CORNERS = new float[][]
|
159
|
{
|
160
|
{ 0.0f, 0.5f, C2},
|
161
|
{ 0.0f, 0.5f, -C2},
|
162
|
{ 0.0f, -0.5f, C2},
|
163
|
{ 0.0f, -0.5f, -C2},
|
164
|
{ C2, 0.0f, 0.5f},
|
165
|
{ C2, 0.0f, -0.5f},
|
166
|
{ -C2, 0.0f, 0.5f},
|
167
|
{ -C2, 0.0f, -0.5f},
|
168
|
{ 0.5f, C2, 0.0f},
|
169
|
{ 0.5f, -C2, 0.0f},
|
170
|
{ -0.5f, C2, 0.0f},
|
171
|
{ -0.5f, -C2, 0.0f},
|
172
|
{ SIN54, SIN54, SIN54},
|
173
|
{ SIN54, SIN54,-SIN54},
|
174
|
{ SIN54,-SIN54, SIN54},
|
175
|
{ SIN54,-SIN54,-SIN54},
|
176
|
{-SIN54, SIN54, SIN54},
|
177
|
{-SIN54, SIN54,-SIN54},
|
178
|
{-SIN54,-SIN54, SIN54},
|
179
|
{-SIN54,-SIN54,-SIN54},
|
180
|
};
|
181
|
|
182
|
static final int[][] mCornerFaceMap =
|
183
|
{
|
184
|
{ 0, 1, 8 },
|
185
|
{ 6, 5,10 },
|
186
|
{ 1, 0,11 },
|
187
|
{ 5, 6, 3 },
|
188
|
{ 0, 9, 4 },
|
189
|
{ 5, 4, 9 },
|
190
|
{ 7, 1, 2 },
|
191
|
{ 2, 6, 7 },
|
192
|
{ 10, 9, 8 },
|
193
|
{ 4, 3,11 },
|
194
|
{ 7,10, 8 },
|
195
|
{ 3, 2,11 },
|
196
|
{ 0, 8, 9 },
|
197
|
{ 9,10, 5 },
|
198
|
{ 0, 4,11 },
|
199
|
{ 4, 5, 3 },
|
200
|
{ 1, 7, 8 },
|
201
|
{ 7, 6,10 },
|
202
|
{ 2, 1,11 },
|
203
|
{ 6, 2, 3 },
|
204
|
};
|
205
|
|
206
|
static final int[] QUAT_EDGE_INDICES =
|
207
|
{
|
208
|
56, 40, 43, 59, 0, 19, 9, 54, 58, 49,
|
209
|
48, 24, 52, 4, 16, 32, 20, 11, 21, 35 ,
|
210
|
37, 30, 8, 28, 36, 44, 1, 46, 12, 47
|
211
|
};
|
212
|
|
213
|
|
214
|
static final int[] QUAT_CORNER_INDICES =
|
215
|
{
|
216
|
0, 2, 3, 1, 40, 31, 41, 30, 39, 35,
|
217
|
36, 34, 56, 32, 43, 21, 48, 28, 42, 23
|
218
|
};
|
219
|
|
220
|
// the quadruple ( corner1, corner2, face1, face2 ) defining an edge.
|
221
|
// In fact the 2 corners already define it, the faces only provide easy
|
222
|
// way to get to know the colors. Order: arbitrary. Face1 arbitrarily on
|
223
|
// the 'left' or right of vector corner1 --> corner2, according to Quat.
|
224
|
static final int[][] mEdgeMap =
|
225
|
{
|
226
|
{ 0, 12, 0, 8}, //0
|
227
|
{ 12, 4, 0, 9},
|
228
|
{ 4, 14, 0, 4},
|
229
|
{ 14, 2, 0, 11},
|
230
|
{ 2, 0, 0, 1},
|
231
|
{ 14, 9, 11, 4}, //5
|
232
|
{ 9, 11, 11, 3},
|
233
|
{ 11, 18, 11, 2},
|
234
|
{ 18, 2, 11, 1},
|
235
|
{ 18, 6, 1, 2},
|
236
|
{ 6, 16, 1, 7}, //10
|
237
|
{ 16, 0, 1, 8},
|
238
|
{ 16, 10, 8, 7},
|
239
|
{ 10, 8, 8, 10},
|
240
|
{ 8, 12, 8, 9},
|
241
|
{ 8, 13, 9, 10}, //15
|
242
|
{ 13, 5, 9, 5},
|
243
|
{ 5, 4, 9, 4},
|
244
|
{ 5, 15, 4, 5},
|
245
|
{ 15, 9, 4, 3},
|
246
|
{ 11, 19, 2, 3}, //20
|
247
|
{ 19, 7, 2, 6},
|
248
|
{ 7, 6, 2, 7},
|
249
|
{ 7, 17, 7, 6},
|
250
|
{ 17, 10, 7, 10},
|
251
|
{ 17, 1, 10, 6}, //25
|
252
|
{ 1, 3, 5, 6},
|
253
|
{ 3, 19, 3, 6},
|
254
|
{ 1, 13, 10, 5},
|
255
|
{ 3, 15, 5, 3},
|
256
|
};
|
257
|
|
258
|
// the five vertices that form a given face. Order: the same as colors
|
259
|
// of the faces in TwistyMinx.
|
260
|
static final int[][] mCenterMap =
|
261
|
{
|
262
|
{ 0, 12, 4, 14, 2},
|
263
|
{ 0, 2, 18, 6, 16},
|
264
|
{ 6, 18, 11, 19, 7},
|
265
|
{ 3, 15, 9, 11, 19},
|
266
|
{ 4, 5, 15, 9, 14},
|
267
|
{ 1, 13, 5, 15, 3},
|
268
|
{ 1, 3, 19, 7, 17},
|
269
|
{10, 16, 6, 7, 17},
|
270
|
{ 0, 12, 8, 10, 16},
|
271
|
{ 8, 13, 5, 4, 12},
|
272
|
{ 1, 13, 8, 10, 17},
|
273
|
{ 2, 14, 9, 11, 18},
|
274
|
};
|
275
|
|
276
|
static final float[][] mCenterCoords = new float[NUM_CENTERS][3];
|
277
|
|
278
|
static
|
279
|
{
|
280
|
for(int center=0; center<NUM_CENTERS; center++)
|
281
|
{
|
282
|
int[] map = mCenterMap[center];
|
283
|
|
284
|
float x = CORNERS[map[0]][0] +
|
285
|
CORNERS[map[1]][0] +
|
286
|
CORNERS[map[2]][0] +
|
287
|
CORNERS[map[3]][0] +
|
288
|
CORNERS[map[4]][0] ;
|
289
|
|
290
|
float y = CORNERS[map[0]][1] +
|
291
|
CORNERS[map[1]][1] +
|
292
|
CORNERS[map[2]][1] +
|
293
|
CORNERS[map[3]][1] +
|
294
|
CORNERS[map[4]][1] ;
|
295
|
|
296
|
float z = CORNERS[map[0]][2] +
|
297
|
CORNERS[map[1]][2] +
|
298
|
CORNERS[map[2]][2] +
|
299
|
CORNERS[map[3]][2] +
|
300
|
CORNERS[map[4]][2] ;
|
301
|
|
302
|
mCenterCoords[center][0] = x/5;
|
303
|
mCenterCoords[center][1] = y/5;
|
304
|
mCenterCoords[center][2] = z/5;
|
305
|
}
|
306
|
}
|
307
|
|
308
|
static final Static4D[] mBasicCornerV, mCurrCornerV;
|
309
|
|
310
|
static
|
311
|
{
|
312
|
mBasicCornerV = new Static4D[3];
|
313
|
mCurrCornerV = new Static4D[3];
|
314
|
|
315
|
mBasicCornerV[0] = new Static4D( (SQ5+1)*0.125f, (SQ5-1)*0.125f, -0.250f, 0.0f );
|
316
|
mBasicCornerV[1] = new Static4D(-(SQ5+1)*0.125f, (SQ5-1)*0.125f, -0.250f, 0.0f );
|
317
|
mBasicCornerV[2] = new Static4D( 0, -0.500f, 0.0f, 0.0f );
|
318
|
}
|
319
|
|
320
|
private int mCurrState;
|
321
|
private int mIndexExcluded;
|
322
|
private ScrambleState[] mStates;
|
323
|
private int[][] mScrambleTable;
|
324
|
private int[] mNumOccurences;
|
325
|
|
326
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
327
|
|
328
|
TwistyMinx(int numLayers, int realSize, Static4D quat, DistortedTexture texture, MeshSquare mesh,
|
329
|
DistortedEffects effects, int[][] moves, ObjectList obj, Resources res, int scrWidth)
|
330
|
{
|
331
|
super(numLayers, realSize, quat, texture, mesh, effects, moves, obj, res, scrWidth);
|
332
|
|
333
|
initializeScrambleStates(numLayers);
|
334
|
}
|
335
|
|
336
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
337
|
|
338
|
private int[] generateL(int numLayers, int index)
|
339
|
{
|
340
|
int rows = (numLayers-1)/2;
|
341
|
int[] ret = new int[3*4*rows];
|
342
|
|
343
|
for(int i=0; i<rows; i++)
|
344
|
{
|
345
|
ret[12*i ] = i;
|
346
|
ret[12*i+ 1] =-2;
|
347
|
ret[12*i+ 2] = index;
|
348
|
ret[12*i+ 3] = i;
|
349
|
ret[12*i+ 4] =-1;
|
350
|
ret[12*i+ 5] = index;
|
351
|
ret[12*i+ 6] = i;
|
352
|
ret[12*i+ 7] =+1;
|
353
|
ret[12*i+ 8] = index;
|
354
|
ret[12*i+ 9] = i;
|
355
|
ret[12*i+10] =+2;
|
356
|
ret[12*i+11] = index;
|
357
|
}
|
358
|
|
359
|
return ret;
|
360
|
}
|
361
|
|
362
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
363
|
|
364
|
private int[] generateR(int numLayers, int index)
|
365
|
{
|
366
|
int rows = (numLayers-1)/2;
|
367
|
int[] ret = new int[3*4*rows];
|
368
|
|
369
|
for(int i=0; i<rows; i++)
|
370
|
{
|
371
|
int lay = rows+i+1;
|
372
|
|
373
|
ret[12*i ] = lay;
|
374
|
ret[12*i+ 1] =-2;
|
375
|
ret[12*i+ 2] = index;
|
376
|
ret[12*i+ 3] = lay;
|
377
|
ret[12*i+ 4] =-1;
|
378
|
ret[12*i+ 5] = index;
|
379
|
ret[12*i+ 6] = lay;
|
380
|
ret[12*i+ 7] =+1;
|
381
|
ret[12*i+ 8] = index;
|
382
|
ret[12*i+ 9] = lay;
|
383
|
ret[12*i+10] =+2;
|
384
|
ret[12*i+11] = index;
|
385
|
}
|
386
|
|
387
|
return ret;
|
388
|
}
|
389
|
|
390
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
391
|
|
392
|
private int[] generateB(int numLayers, int index)
|
393
|
{
|
394
|
int rows = (numLayers-1);
|
395
|
int half = rows/2;
|
396
|
int[] ret = new int[3*4*rows];
|
397
|
|
398
|
for(int i=0; i<rows; i++)
|
399
|
{
|
400
|
int ind = i<half? index : index+1;
|
401
|
int lay = i<half? i : i+1;
|
402
|
|
403
|
ret[12*i ] = lay;
|
404
|
ret[12*i+ 1] =-2;
|
405
|
ret[12*i+ 2] = ind;
|
406
|
ret[12*i+ 3] = lay;
|
407
|
ret[12*i+ 4] =-1;
|
408
|
ret[12*i+ 5] = ind;
|
409
|
ret[12*i+ 6] = lay;
|
410
|
ret[12*i+ 7] =+1;
|
411
|
ret[12*i+ 8] = ind;
|
412
|
ret[12*i+ 9] = lay;
|
413
|
ret[12*i+10] =+2;
|
414
|
ret[12*i+11] = ind;
|
415
|
}
|
416
|
|
417
|
return ret;
|
418
|
}
|
419
|
|
420
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
421
|
|
422
|
private void initializeScrambleStates(int numLayers)
|
423
|
{
|
424
|
int[] LEFT0 = generateL(numLayers,1);
|
425
|
int[] RIGH0 = generateR(numLayers,2);
|
426
|
int[] LEFT1 = generateL(numLayers,3);
|
427
|
int[] RIGH1 = generateR(numLayers,4);
|
428
|
int[] LEFT2 = generateL(numLayers,5);
|
429
|
int[] RIGH2 = generateR(numLayers,6);
|
430
|
int[] LEFT3 = generateL(numLayers,7);
|
431
|
int[] RIGH3 = generateR(numLayers,8);
|
432
|
int[] LEFT4 = generateL(numLayers,9);
|
433
|
int[] RIGH4 = generateR(numLayers,10);
|
434
|
int[] LEFT5 = generateL(numLayers,11);
|
435
|
int[] RIGH5 = generateR(numLayers,12);
|
436
|
|
437
|
int[] BOTH1 = generateB(numLayers,1);
|
438
|
int[] BOTH3 = generateB(numLayers,3);
|
439
|
int[] BOTH5 = generateB(numLayers,5);
|
440
|
int[] BOTH7 = generateB(numLayers,7);
|
441
|
int[] BOTH9 = generateB(numLayers,9);
|
442
|
int[] BOTH11= generateB(numLayers,11);
|
443
|
|
444
|
mStates = new ScrambleState[]
|
445
|
{
|
446
|
new ScrambleState( new int[][] { BOTH1,BOTH3,BOTH5,BOTH7,BOTH9,BOTH11 } ), // beg
|
447
|
new ScrambleState( new int[][] { {} ,RIGH1,LEFT2,RIGH3,LEFT4,LEFT5 } ), // 0L
|
448
|
new ScrambleState( new int[][] { {} ,LEFT1,RIGH2,LEFT3,RIGH4,RIGH5 } ), // 0R
|
449
|
new ScrambleState( new int[][] { RIGH0,{} ,LEFT2,RIGH3,RIGH4,RIGH5 } ), // 1L
|
450
|
new ScrambleState( new int[][] { LEFT0,{} ,RIGH2,LEFT3,LEFT4,LEFT5 } ), // 1R
|
451
|
new ScrambleState( new int[][] { LEFT0,LEFT1,{} ,RIGH3,LEFT4,RIGH5 } ), // 2L
|
452
|
new ScrambleState( new int[][] { RIGH0,RIGH1,{} ,LEFT3,RIGH4,LEFT5 } ), // 2R
|
453
|
new ScrambleState( new int[][] { RIGH0,RIGH1,RIGH2,{} ,LEFT4,RIGH5 } ), // 3L
|
454
|
new ScrambleState( new int[][] { LEFT0,LEFT1,LEFT2,{} ,RIGH4,LEFT5 } ), // 3R
|
455
|
new ScrambleState( new int[][] { LEFT0,RIGH1,LEFT2,LEFT3,{} ,RIGH5 } ), // 4L
|
456
|
new ScrambleState( new int[][] { RIGH0,LEFT1,RIGH2,RIGH3,{} ,LEFT5 } ), // 4R
|
457
|
new ScrambleState( new int[][] { LEFT0,RIGH1,RIGH2,RIGH3,RIGH4,{} } ), // 5L
|
458
|
new ScrambleState( new int[][] { RIGH0,LEFT1,LEFT2,LEFT3,LEFT4,{} } ), // 5R
|
459
|
};
|
460
|
}
|
461
|
|
462
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
463
|
|
464
|
int[] getSolvedQuats(int cubit, int numLayers)
|
465
|
{
|
466
|
int status = retCubitSolvedStatus(cubit,numLayers);
|
467
|
return status<0 ? null : buildSolvedQuats(MovementMinx.FACE_AXIS[mFaceMap[status]],QUATS);
|
468
|
}
|
469
|
|
470
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
471
|
|
472
|
Static4D[] getQuats()
|
473
|
{
|
474
|
return QUATS;
|
475
|
}
|
476
|
|
477
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
478
|
|
479
|
int getNumFaces()
|
480
|
{
|
481
|
return FACE_COLORS.length;
|
482
|
}
|
483
|
|
484
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
485
|
|
486
|
int getSolvedFunctionIndex()
|
487
|
{
|
488
|
return 0;
|
489
|
}
|
490
|
|
491
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
492
|
|
493
|
boolean shouldResetTextureMaps()
|
494
|
{
|
495
|
return false;
|
496
|
}
|
497
|
|
498
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
499
|
|
500
|
int getNumCubitFaces()
|
501
|
{
|
502
|
return FACES_PER_CUBIT;
|
503
|
}
|
504
|
|
505
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
506
|
|
507
|
float returnMultiplier()
|
508
|
{
|
509
|
return 2.0f;
|
510
|
}
|
511
|
|
512
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
513
|
|
514
|
private void initializeScrambling()
|
515
|
{
|
516
|
int numLayers = getNumLayers();
|
517
|
|
518
|
if( mScrambleTable ==null )
|
519
|
{
|
520
|
mScrambleTable = new int[NUM_AXIS][numLayers];
|
521
|
}
|
522
|
if( mNumOccurences ==null )
|
523
|
{
|
524
|
int max=0;
|
525
|
|
526
|
for (ScrambleState mState : mStates)
|
527
|
{
|
528
|
int tmp = mState.getTotal(-1);
|
529
|
if (max < tmp) max = tmp;
|
530
|
}
|
531
|
|
532
|
mNumOccurences = new int[max];
|
533
|
}
|
534
|
|
535
|
for(int i=0; i<NUM_AXIS; i++)
|
536
|
for(int j=0; j<numLayers; j++) mScrambleTable[i][j] = 0;
|
537
|
}
|
538
|
|
539
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
540
|
// PUBLIC API
|
541
|
|
542
|
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles)
|
543
|
{
|
544
|
if( curr==0 )
|
545
|
{
|
546
|
mCurrState = 0;
|
547
|
mIndexExcluded =-1;
|
548
|
initializeScrambling();
|
549
|
}
|
550
|
|
551
|
int[] info= mStates[mCurrState].getRandom(rnd, mIndexExcluded, mScrambleTable, mNumOccurences);
|
552
|
|
553
|
scramble[curr][0] = info[0];
|
554
|
scramble[curr][1] = info[1];
|
555
|
scramble[curr][2] = info[2];
|
556
|
|
557
|
mCurrState = info[3];
|
558
|
mIndexExcluded = info[0];
|
559
|
}
|
560
|
|
561
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
562
|
|
563
|
public Static3D[] getRotationAxis()
|
564
|
{
|
565
|
return ROT_AXIS;
|
566
|
}
|
567
|
|
568
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
569
|
|
570
|
public int[] getBasicAngle()
|
571
|
{
|
572
|
return BASIC_ANGLE;
|
573
|
}
|
574
|
}
|