1 |
eaee1ddc
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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.library.main.DistortedEffects;
|
25 |
|
|
import org.distorted.library.main.DistortedTexture;
|
26 |
|
|
import org.distorted.library.mesh.MeshSquare;
|
27 |
|
|
import org.distorted.library.type.Static4D;
|
28 |
6fd4a72c
|
Leszek Koltunski
|
import org.distorted.main.R;
|
29 |
eaee1ddc
|
Leszek Koltunski
|
|
30 |
2067efd8
|
Leszek Koltunski
|
import java.util.Random;
|
31 |
|
|
|
32 |
eaee1ddc
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
33 |
|
|
|
34 |
9c2f0c91
|
Leszek Koltunski
|
public class TwistyDino6 extends TwistyDino
|
35 |
eaee1ddc
|
Leszek Koltunski
|
{
|
36 |
|
|
private static final int[] mFaceMap = {4,2, 0,4, 4,3, 1,4,
|
37 |
|
|
2,0, 3,0, 3,1, 2,1,
|
38 |
|
|
5,2, 0,5, 5,3, 1,5 };
|
39 |
|
|
|
40 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
41 |
|
|
|
42 |
169219a7
|
Leszek Koltunski
|
TwistyDino6(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
|
43 |
|
|
DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
|
44 |
eaee1ddc
|
Leszek Koltunski
|
{
|
45 |
9c2f0c91
|
Leszek Koltunski
|
super(size, quat, texture, mesh, effects, moves, ObjectList.DINO, res, scrWidth);
|
46 |
eaee1ddc
|
Leszek Koltunski
|
}
|
47 |
|
|
|
48 |
a480ee80
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
49 |
|
|
// Dino6 is solved if and only if:
|
50 |
|
|
//
|
51 |
|
|
// All four 'X' cubits (i.e. those whose longest edge goes along the X axis) are rotated
|
52 |
|
|
// by the same quaternion qX, similarly all four 'Y' cubits by the same qY and all four 'Z'
|
53 |
|
|
// by the same qZ, and then either:
|
54 |
|
|
//
|
55 |
|
|
// a) qX = qY = qZ
|
56 |
|
|
// b) qY = qX*Q2 and qZ = qX*Q8 (i.e. swap of WHITE and YELLOW faces)
|
57 |
|
|
// c) qX = qY*Q2 and qZ = qY*Q10 (i.e. swap of BLUE and GREEN faces)
|
58 |
|
|
// d) qX = qZ*Q8 and qY = qZ*Q10 (i.e. swap of RED and BROWN faces)
|
59 |
|
|
//
|
60 |
|
|
// BUT: cases b), c) and d) are really the same - it's all just a mirror image of the original.
|
61 |
|
|
//
|
62 |
|
|
// X cubits: 0, 2, 8, 10
|
63 |
|
|
// Y cubits: 1, 3, 9, 11
|
64 |
|
|
// Z cubits: 4, 5, 6, 7
|
65 |
|
|
|
66 |
|
|
int[] getSolvedQuats(int cubit, int numLayers)
|
67 |
|
|
{
|
68 |
|
|
switch(cubit)
|
69 |
|
|
{
|
70 |
|
|
case 0: case 2: case 8: case 10: return null;
|
71 |
|
|
case 1: case 3: case 9: case 11: return new int[] {2};
|
72 |
|
|
case 4: case 5: case 6: case 7: return new int[] {8};
|
73 |
|
|
}
|
74 |
|
|
|
75 |
|
|
return null;
|
76 |
|
|
}
|
77 |
|
|
|
78 |
eaee1ddc
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
79 |
|
|
|
80 |
|
|
int getFaceColor(int cubit, int cubitface, int size)
|
81 |
|
|
{
|
82 |
|
|
switch(cubitface)
|
83 |
|
|
{
|
84 |
|
|
case 0 : return mFaceMap[2*cubit];
|
85 |
|
|
case 1 : return mFaceMap[2*cubit+1];
|
86 |
|
|
default: return NUM_FACES;
|
87 |
|
|
}
|
88 |
|
|
}
|
89 |
|
|
|
90 |
169219a7
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
91 |
|
|
|
92 |
|
|
int getSolvedFunctionIndex()
|
93 |
|
|
{
|
94 |
|
|
return 0;
|
95 |
|
|
}
|
96 |
|
|
|
97 |
eaee1ddc
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
98 |
|
|
|
99 |
|
|
boolean shouldResetTextureMaps()
|
100 |
|
|
{
|
101 |
|
|
return false;
|
102 |
|
|
}
|
103 |
|
|
|
104 |
2067efd8
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
105 |
|
|
|
106 |
9f171eba
|
Leszek Koltunski
|
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int total)
|
107 |
2067efd8
|
Leszek Koltunski
|
{
|
108 |
9f171eba
|
Leszek Koltunski
|
if( curr==0 )
|
109 |
bbc6471c
|
Leszek Koltunski
|
{
|
110 |
9f171eba
|
Leszek Koltunski
|
scramble[curr][0] = rnd.nextInt(NUM_AXIS);
|
111 |
|
|
scramble[curr][1] = rnd.nextFloat()<=0.5f ? 0:2;
|
112 |
bbc6471c
|
Leszek Koltunski
|
}
|
113 |
|
|
else
|
114 |
|
|
{
|
115 |
8db55f55
|
Leszek Koltunski
|
int newVector = rnd.nextInt(NUM_AXIS-1);
|
116 |
9f171eba
|
Leszek Koltunski
|
scramble[curr][0] = (newVector>=scramble[curr-1][0] ? newVector+1 : newVector);
|
117 |
|
|
scramble[curr][1] = scramble[curr-1][0]+scramble[curr][0]==3 ? 2-scramble[curr-1][1] : scramble[curr-1][1];
|
118 |
bbc6471c
|
Leszek Koltunski
|
}
|
119 |
|
|
|
120 |
5043d5d0
|
Leszek Koltunski
|
switch( rnd.nextInt(2) )
|
121 |
|
|
{
|
122 |
9f171eba
|
Leszek Koltunski
|
case 0: scramble[curr][2] = -1; break;
|
123 |
|
|
case 1: scramble[curr][2] = 1; break;
|
124 |
5043d5d0
|
Leszek Koltunski
|
}
|
125 |
2067efd8
|
Leszek Koltunski
|
}
|
126 |
|
|
|
127 |
6fd4a72c
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
128 |
|
|
|
129 |
|
|
public int getObjectName(int numLayers)
|
130 |
|
|
{
|
131 |
|
|
return R.string.dino3;
|
132 |
|
|
}
|
133 |
|
|
|
134 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
135 |
|
|
|
136 |
|
|
public int getInventor(int numLayers)
|
137 |
|
|
{
|
138 |
|
|
return R.string.dino3_inventor;
|
139 |
|
|
}
|
140 |
eaee1ddc
|
Leszek Koltunski
|
}
|