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 org.distorted.objectlib.R;
|
13
|
import org.distorted.objectlib.helpers.OperatingSystemInterface;
|
14
|
|
15
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
16
|
|
17
|
public class TBDino6 extends TBDino
|
18
|
{
|
19
|
private static final int SOLVED1 = 0;
|
20
|
private static final int SOLVED2 = 17977621; // quats (0,10,0,10, 11,11,11,11, 0,10,0,10)
|
21
|
|
22
|
private OperatingSystemInterface mOS;
|
23
|
|
24
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
25
|
|
26
|
public TBDino6()
|
27
|
{
|
28
|
super();
|
29
|
}
|
30
|
|
31
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
32
|
|
33
|
public TBDino6(OperatingSystemInterface os)
|
34
|
{
|
35
|
super(os,new int[] {R.raw.dino_3_pruning3,R.raw.dino_3_pruning4},new int[] {R.raw.dino_3_pruning10});
|
36
|
|
37
|
mOS = os;
|
38
|
}
|
39
|
|
40
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
41
|
// specifically for the tablebase
|
42
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
43
|
// two solved positions: original and mirrored (left face swapped with right)
|
44
|
|
45
|
@Override
|
46
|
int[] getSolvedIndices()
|
47
|
{
|
48
|
return new int[] {SOLVED1,SOLVED2};
|
49
|
}
|
50
|
|
51
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
52
|
// ditto
|
53
|
|
54
|
@Override
|
55
|
boolean isSolved(int index)
|
56
|
{
|
57
|
return index==SOLVED1 || index==SOLVED2;
|
58
|
}
|
59
|
|
60
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
61
|
|
62
|
int getSize()
|
63
|
{
|
64
|
return 19958400; // see https://www.jaapsch.net/puzzles/dinocube.htm
|
65
|
}
|
66
|
|
67
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
68
|
|
69
|
int getMinScramble()
|
70
|
{
|
71
|
return 8;
|
72
|
}
|
73
|
|
74
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
75
|
|
76
|
int[] getMidPruningLevels()
|
77
|
{
|
78
|
return new int[] {3,4};
|
79
|
}
|
80
|
|
81
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
82
|
|
83
|
int[] getHighPruningLevels()
|
84
|
{
|
85
|
return new int[] {10};
|
86
|
}
|
87
|
|
88
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
89
|
|
90
|
int getGodsNumber()
|
91
|
{
|
92
|
return 10;
|
93
|
}
|
94
|
|
95
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
96
|
|
97
|
public static int getIndexFromPerm(int[] perm)
|
98
|
{
|
99
|
int[] perm11 = new int[11];
|
100
|
|
101
|
for(int i=0; i<11; i++)
|
102
|
{
|
103
|
if( perm[i+1]<=0 ) return -1;
|
104
|
perm11[i] = perm[i+1]-1;
|
105
|
}
|
106
|
|
107
|
return TablebaseHelpers.computeEvenPermutationNum(perm11);
|
108
|
}
|
109
|
|
110
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
111
|
|
112
|
int[] getQuats(int index)
|
113
|
{
|
114
|
int[] perm11 = new int[11];
|
115
|
TablebaseHelpers.getEvenPermutationFromNum(perm11,index);
|
116
|
int[] perm = new int[12];
|
117
|
for(int i=1; i<12; i++) perm[i] = perm11[i-1]+1;
|
118
|
return getQuatsFromPerm(perm);
|
119
|
}
|
120
|
|
121
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
122
|
|
123
|
int getIndex(int[] quats)
|
124
|
{
|
125
|
normalizeQuats(quats);
|
126
|
int[] perm = getPermFromQuats(quats);
|
127
|
int ret = getIndexFromPerm(perm);
|
128
|
|
129
|
if( ret<0 )
|
130
|
{
|
131
|
if( mOS!=null )
|
132
|
{
|
133
|
StringBuilder sb = new StringBuilder();
|
134
|
|
135
|
for(int i=0; i<12; i++)
|
136
|
{
|
137
|
sb.append(quats[i]);
|
138
|
sb.append(' ');
|
139
|
}
|
140
|
|
141
|
mOS.reportError("TBDino6 getIndex: "+sb);
|
142
|
}
|
143
|
return 0;
|
144
|
}
|
145
|
|
146
|
return ret;
|
147
|
}
|
148
|
}
|
149
|
|