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