Revision efe00e0f
Added by Leszek Koltunski over 4 years ago
src/main/java/org/distorted/states/RubikStateSolver.java | ||
---|---|---|
68 | 68 |
/////////////////////////////////////////////////// |
69 | 69 |
|
70 | 70 |
Solver(String str, RubikActivity act) |
71 |
{
|
|
72 |
mCubeString = str;
|
|
73 |
mAct = act;
|
|
74 |
}
|
|
71 |
{
|
|
72 |
mCubeString = str;
|
|
73 |
mAct = act;
|
|
74 |
}
|
|
75 | 75 |
|
76 | 76 |
/////////////////////////////////////////////////// |
77 | 77 |
|
78 | 78 |
public void start() |
79 | 79 |
{ |
80 |
Thread thr = new Thread(this);
|
|
81 |
thr.start();
|
|
80 |
Thread thr = new Thread(this);
|
|
81 |
thr.start();
|
|
82 | 82 |
} |
83 | 83 |
|
84 | 84 |
/////////////////////////////////////////////////// |
85 | 85 |
|
86 | 86 |
public void interrupt() |
87 | 87 |
{ |
88 |
org.distorted.solvers.cube3.Search.interrupt();
|
|
88 |
org.distorted.solvers.cube3.Search.interrupt();
|
|
89 | 89 |
} |
90 | 90 |
|
91 | 91 |
/////////////////////////////////////////////////// |
92 | 92 |
|
93 | 93 |
public void run() |
94 |
{
|
|
95 |
Resources res = mAct.getResources();
|
|
96 |
String result;
|
|
94 |
{
|
|
95 |
Resources res = mAct.getResources();
|
|
96 |
String result;
|
|
97 | 97 |
|
98 |
if( !org.distorted.solvers.cube3.Search.prepare(res) )
|
|
99 |
result= "Error 9";
|
|
100 |
else
|
|
101 |
result = org.distorted.solvers.cube3.Search.solution(mCubeString, 24, 20);
|
|
98 |
if( !org.distorted.solvers.cube3.Search.prepare(res) )
|
|
99 |
result= "Error 9";
|
|
100 |
else
|
|
101 |
result = org.distorted.solvers.cube3.Search.solution(mCubeString, 24, 20);
|
|
102 | 102 |
|
103 | 103 |
mSolving = false; |
104 | 104 |
|
105 |
if (result.contains("Error"))
|
|
106 |
{
|
|
107 |
switch (result.charAt(result.length() - 1))
|
|
108 |
{
|
|
109 |
case '1': result = res.getString(R.string.error1); break;
|
|
110 |
case '2': result = res.getString(R.string.error2); break;
|
|
111 |
case '3': result = res.getString(R.string.error3); break;
|
|
112 |
case '4': result = res.getString(R.string.error4); break;
|
|
113 |
case '5': result = res.getString(R.string.error5); break;
|
|
114 |
case '6': result = res.getString(R.string.error6); break;
|
|
115 |
case '7': result = res.getString(R.string.error7); break;
|
|
116 |
case '8': result = res.getString(R.string.error8); break;
|
|
117 |
case '9': result = res.getString(R.string.error9); break;
|
|
118 |
}
|
|
105 |
if (result.contains("Error"))
|
|
106 |
{
|
|
107 |
switch (result.charAt(result.length() - 1))
|
|
108 |
{
|
|
109 |
case '1': result = res.getString(R.string.error1); break;
|
|
110 |
case '2': result = res.getString(R.string.error2); break;
|
|
111 |
case '3': result = res.getString(R.string.error3); break;
|
|
112 |
case '4': result = res.getString(R.string.error4); break;
|
|
113 |
case '5': result = res.getString(R.string.error5); break;
|
|
114 |
case '6': result = res.getString(R.string.error6); break;
|
|
115 |
case '7': result = res.getString(R.string.error7); break;
|
|
116 |
case '8': result = res.getString(R.string.error8); break;
|
|
117 |
case '9': result = res.getString(R.string.error9); break;
|
|
118 |
}
|
|
119 | 119 |
|
120 | 120 |
RubikDialogSolverError dialog = new RubikDialogSolverError(); |
121 | 121 |
Bundle bundle = new Bundle(); |
122 | 122 |
bundle.putString("error", result ); |
123 | 123 |
dialog.setArguments(bundle); |
124 | 124 |
dialog.show( mAct.getSupportFragmentManager(), null); |
125 |
}
|
|
126 |
else
|
|
125 |
}
|
|
126 |
else
|
|
127 | 127 |
{ |
128 | 128 |
setSolved( mAct, org.distorted.solvers.cube3.Search.numMoves(), result); |
129 | 129 |
} |
130 |
}
|
|
130 |
}
|
|
131 | 131 |
} |
132 | 132 |
|
133 | 133 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Formatting: remove tabs.