|
1 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
2 |
// Copyright 2023 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.tablebases;
|
|
11 |
|
|
12 |
import static org.distorted.objectlib.main.TwistyObject.SQ3;
|
|
13 |
|
|
14 |
import android.content.res.Resources;
|
|
15 |
|
|
16 |
import org.distorted.library.type.Static3D;
|
|
17 |
|
|
18 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
19 |
|
|
20 |
public class TBDino4 extends TablebasesAbstract
|
|
21 |
{
|
|
22 |
private static final int INDEX_INVERTED = 13379863;
|
|
23 |
private int[][] mAngles;
|
|
24 |
|
|
25 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
26 |
|
|
27 |
public TBDino4()
|
|
28 |
{
|
|
29 |
super();
|
|
30 |
}
|
|
31 |
|
|
32 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
33 |
|
|
34 |
public TBDino4(Resources res)
|
|
35 |
{
|
|
36 |
super(res,0);
|
|
37 |
}
|
|
38 |
|
|
39 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
40 |
|
|
41 |
int[][] getBasicAngles()
|
|
42 |
{
|
|
43 |
if( mAngles==null )
|
|
44 |
{
|
|
45 |
int[] tmp = {3,3,3};
|
|
46 |
mAngles = new int[][] { tmp,tmp,tmp,tmp };
|
|
47 |
}
|
|
48 |
|
|
49 |
return mAngles;
|
|
50 |
}
|
|
51 |
|
|
52 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
53 |
|
|
54 |
Static3D[] getRotationAxis()
|
|
55 |
{
|
|
56 |
return new Static3D[]
|
|
57 |
{
|
|
58 |
new Static3D( SQ3/3, SQ3/3, SQ3/3),
|
|
59 |
new Static3D( SQ3/3, SQ3/3,-SQ3/3),
|
|
60 |
new Static3D( SQ3/3,-SQ3/3, SQ3/3),
|
|
61 |
new Static3D( SQ3/3,-SQ3/3,-SQ3/3)
|
|
62 |
};
|
|
63 |
}
|
|
64 |
|
|
65 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
66 |
|
|
67 |
float[][] getPosition()
|
|
68 |
{
|
|
69 |
return new float[][]
|
|
70 |
{
|
|
71 |
{ 0.0f, 1.5f, 1.5f },
|
|
72 |
{ 1.5f, 0.0f, 1.5f },
|
|
73 |
{ 0.0f,-1.5f, 1.5f },
|
|
74 |
{-1.5f, 0.0f, 1.5f },
|
|
75 |
{ 1.5f, 1.5f, 0.0f },
|
|
76 |
{ 1.5f,-1.5f, 0.0f },
|
|
77 |
{-1.5f,-1.5f, 0.0f },
|
|
78 |
{-1.5f, 1.5f, 0.0f },
|
|
79 |
{ 0.0f, 1.5f,-1.5f },
|
|
80 |
{ 1.5f, 0.0f,-1.5f },
|
|
81 |
{ 0.0f,-1.5f,-1.5f },
|
|
82 |
{-1.5f, 0.0f,-1.5f }
|
|
83 |
};
|
|
84 |
}
|
|
85 |
|
|
86 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
87 |
|
|
88 |
float[][] getCuts()
|
|
89 |
{
|
|
90 |
float[] cut = new float[] { -SQ3/3, SQ3/3 };
|
|
91 |
return new float[][] { cut,cut,cut,cut };
|
|
92 |
}
|
|
93 |
|
|
94 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
95 |
// exclude the middle layer and movements of edge[0].
|
|
96 |
|
|
97 |
boolean[][] getRotatable()
|
|
98 |
{
|
|
99 |
boolean[] tmp = {true,false,true};
|
|
100 |
return new boolean[][] { tmp,tmp,tmp,tmp };
|
|
101 |
}
|
|
102 |
|
|
103 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
104 |
// specifically for the tablebase
|
|
105 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
106 |
// two solved positions: original and mirrored (left face swapped with right)
|
|
107 |
|
|
108 |
@Override
|
|
109 |
int[] getSolvedIndices()
|
|
110 |
{
|
|
111 |
return new int[] {0,INDEX_INVERTED};
|
|
112 |
}
|
|
113 |
|
|
114 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
115 |
// ditto
|
|
116 |
|
|
117 |
@Override
|
|
118 |
boolean isSolved(int index)
|
|
119 |
{
|
|
120 |
return index==0 || index==INDEX_INVERTED;
|
|
121 |
}
|
|
122 |
|
|
123 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
124 |
// we can never really move the top-front edge, because if we do so, we would also rotate the
|
|
125 |
// rotation axis themselves! (see getIndex() where the cubit quats are normalized so that quat[0]
|
|
126 |
// - i.e. the front-top edge - is always 0).
|
|
127 |
// That's why map the moves (0,2,X) to (0,0&1,-X) and (3,0,X) to (3,1&2,-X)
|
|
128 |
|
|
129 |
@Override
|
|
130 |
int[] newMove(int axis, int layer, int angle)
|
|
131 |
{
|
|
132 |
if( axis==0 && layer==2 ) return new int[] { axis, 3, angle==1 ? 1:-1};
|
|
133 |
if( axis==3 && layer==0 ) return new int[] { axis, 6, angle==1 ? 1:-1};
|
|
134 |
|
|
135 |
int maxAngle = mAngles[axis][layer];
|
|
136 |
angle = maxAngle-angle;
|
|
137 |
if( angle> 0.5f*maxAngle ) angle -= maxAngle;
|
|
138 |
return new int[] { axis, (1<<layer), angle };
|
|
139 |
}
|
|
140 |
|
|
141 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
142 |
|
|
143 |
@Override
|
|
144 |
void convertMoves(int[][] moves)
|
|
145 |
{
|
|
146 |
for(int[] move : moves )
|
|
147 |
{
|
|
148 |
int[] newMove = newMove(move[0],move[1],move[2]);
|
|
149 |
|
|
150 |
move[0] = newMove[0];
|
|
151 |
move[1] = newMove[1];
|
|
152 |
move[2] = newMove[2];
|
|
153 |
}
|
|
154 |
}
|
|
155 |
|
|
156 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
157 |
// 15408 really (see https://www.jaapsch.net/puzzles/dinocube.htm) but we do not assign indices
|
|
158 |
// tightly but do (11 over 2)*(9 over 3)*(6 over 3) = 92400.
|
|
159 |
|
|
160 |
int getSize()
|
|
161 |
{
|
|
162 |
return 92400;
|
|
163 |
}
|
|
164 |
|
|
165 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
166 |
|
|
167 |
int getMinScramble()
|
|
168 |
{
|
|
169 |
return 5;
|
|
170 |
}
|
|
171 |
|
|
172 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
173 |
|
|
174 |
public static int indexFromPartition(int[] partition)
|
|
175 |
{
|
|
176 |
return 0;
|
|
177 |
}
|
|
178 |
|
|
179 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
180 |
|
|
181 |
private static int[] quatsFromPartition(int[] partition)
|
|
182 |
{
|
|
183 |
return null;
|
|
184 |
}
|
|
185 |
|
|
186 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
187 |
|
|
188 |
private static int[] partitionFromQuats(int[] quats)
|
|
189 |
{
|
|
190 |
return null;
|
|
191 |
}
|
|
192 |
|
|
193 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
194 |
|
|
195 |
private static int[] partitionFromIndex(int index)
|
|
196 |
{
|
|
197 |
return null;
|
|
198 |
}
|
|
199 |
|
|
200 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
201 |
|
|
202 |
int[] getQuats(int index)
|
|
203 |
{
|
|
204 |
int[] partition = partitionFromIndex(index);
|
|
205 |
return quatsFromPartition(partition);
|
|
206 |
}
|
|
207 |
|
|
208 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
209 |
|
|
210 |
int getIndex(int[] quats)
|
|
211 |
{
|
|
212 |
int[] partition = partitionFromQuats(quats);
|
|
213 |
return indexFromPartition(partition);
|
|
214 |
}
|
|
215 |
}
|
|
216 |
|
Dino4 solver: skeleton.