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.solvers;
|
11
|
|
12
|
import android.content.res.Resources;
|
13
|
|
14
|
import org.distorted.main.R;
|
15
|
import org.distorted.objectlib.main.ObjectSignatures;
|
16
|
import org.distorted.objectlib.main.TwistyObject;
|
17
|
import org.distorted.objectlib.tablebases.ImplementedTablebasesList;
|
18
|
import org.distorted.objectlib.tablebases.TablebasesAbstract;
|
19
|
|
20
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
21
|
|
22
|
public class SolverDino6 extends SolverTablebase
|
23
|
{
|
24
|
private static final int ERROR_EDGE_MISSING = -1;
|
25
|
private static final int ERROR_EDGE_CANNOT = -2;
|
26
|
private static final int ERROR_EDGE_TWISTED = -3;
|
27
|
|
28
|
private TablebasesAbstract mSolver;
|
29
|
private int[] mFaceColors;
|
30
|
private int mErrorColor1, mErrorColor2;
|
31
|
|
32
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
33
|
|
34
|
public SolverDino6(Resources res, TwistyObject object)
|
35
|
{
|
36
|
super(res,object);
|
37
|
}
|
38
|
|
39
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
40
|
|
41
|
public int tablebaseIndex(TwistyObject object)
|
42
|
{
|
43
|
int[][] edges = new int[12][2];
|
44
|
return 0;
|
45
|
}
|
46
|
|
47
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
48
|
|
49
|
private int getColorIndex3(int color)
|
50
|
{
|
51
|
switch(color)
|
52
|
{
|
53
|
case 0: return R.string.color_yellow3;
|
54
|
case 1: return R.string.color_white3;
|
55
|
case 2: return R.string.color_blue3;
|
56
|
case 3: return R.string.color_green3;
|
57
|
case 4: return R.string.color_red3;
|
58
|
case 5: return R.string.color_orange3;
|
59
|
}
|
60
|
|
61
|
return -1;
|
62
|
}
|
63
|
|
64
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
65
|
|
66
|
private int getColorIndex6(int color)
|
67
|
{
|
68
|
switch(color)
|
69
|
{
|
70
|
case 0: return R.string.color_yellow6;
|
71
|
case 1: return R.string.color_white6;
|
72
|
case 2: return R.string.color_blue6;
|
73
|
case 3: return R.string.color_green6;
|
74
|
case 4: return R.string.color_red6;
|
75
|
case 5: return R.string.color_orange6;
|
76
|
}
|
77
|
|
78
|
return -1;
|
79
|
}
|
80
|
|
81
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
82
|
|
83
|
private String edgeMissingError(Resources res, int color0, int color1)
|
84
|
{
|
85
|
int j0 = getColorIndex3(color0);
|
86
|
int j1 = getColorIndex6(color1);
|
87
|
|
88
|
String c0 = res.getString(j0);
|
89
|
String c1 = res.getString(j1);
|
90
|
|
91
|
return res.getString(R.string.solver_generic_missing_edge,c0,c1);
|
92
|
}
|
93
|
|
94
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
95
|
|
96
|
private String edgeTwistedError(Resources res, int color0, int color1)
|
97
|
{
|
98
|
int j0 = getColorIndex3(color0);
|
99
|
int j1 = getColorIndex6(color1);
|
100
|
|
101
|
String c0 = res.getString(j0);
|
102
|
String c1 = res.getString(j1);
|
103
|
|
104
|
return res.getString(R.string.solver_generic_twisted_edge,c0,c1);
|
105
|
}
|
106
|
|
107
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
108
|
|
109
|
public String error(int index, Resources res)
|
110
|
{
|
111
|
switch(index)
|
112
|
{
|
113
|
case ERROR_EDGE_MISSING : return edgeMissingError(res,mErrorColor1,mErrorColor2);
|
114
|
case ERROR_EDGE_TWISTED : return edgeTwistedError(res,mErrorColor1,mErrorColor2);
|
115
|
case ERROR_EDGE_CANNOT : return res.getString(R.string.solver_generic_edges_cannot);
|
116
|
}
|
117
|
|
118
|
return null;
|
119
|
}
|
120
|
|
121
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
122
|
|
123
|
public int[][] solution(int index, Resources res)
|
124
|
{
|
125
|
if( mSolver==null )
|
126
|
{
|
127
|
mSolver = ImplementedTablebasesList.createUnpacked(ObjectSignatures.DINO_3);
|
128
|
|
129
|
if( mSolver!=null )
|
130
|
{
|
131
|
mSolver.createTablebase(-1);
|
132
|
}
|
133
|
}
|
134
|
|
135
|
return mSolver!=null ? mSolver.solution(index,null) : null;
|
136
|
}
|
137
|
}
|
138
|
|