Project

General

Profile

« Previous | Next » 

Revision f702f4ef

Added by Leszek Koltunski over 2 years ago

Make error reporting in the Solver a bit better.

View differences:

src/main/java/org/distorted/solvers/SolverMain.java
26 26
  private final Resources mRes;
27 27
  private final TwistyObject mObject;
28 28
  private final long mSignature;
29
  private int mColorID;
29 30

  
30 31
///////////////////////////////////////////////////////////////////////////////////////////////////
31 32

  
......
66 67

  
67 68
    SolverSearch.prepare(mRes);
68 69
    String objectPosition = prepareCube3position();
69
    result = SolverSearch.solution(objectPosition, 24, 20);
70
    int check = checkPosition(objectPosition);
70 71

  
71
    if (result.contains("Error"))
72
    if( check<0 )
72 73
      {
73
      switch (result.charAt(result.length() - 1))
74
      result = SolverSearch.solution(objectPosition, 24, 20);
75

  
76
      if (result.contains("Error"))
74 77
        {
75
        case '1': result = mRes.getString(R.string.solver_cube3_error1); break;
76
        case '2': result = mRes.getString(R.string.solver_cube3_error2); break;
77
        case '3': result = mRes.getString(R.string.solver_cube3_error3); break;
78
        case '4': result = mRes.getString(R.string.solver_cube3_error4); break;
79
        case '5': result = mRes.getString(R.string.solver_cube3_error5); break;
80
        case '6': result = mRes.getString(R.string.solver_cube3_error6); break;
81
        case '7': result = mRes.getString(R.string.solver_cube3_error7); break;
82
        case '8': result = mRes.getString(R.string.solver_cube3_error8); break;
83
        case '9': result = mRes.getString(R.string.solver_cube3_error9); break;
78
        switch (result.charAt(result.length() - 1))
79
          {
80
          case '1': result = mRes.getString(R.string.solver_cube3_error1); break;
81
          case '2': result = mRes.getString(R.string.solver_cube3_error2); break;
82
          case '3': result = mRes.getString(R.string.solver_cube3_error3); break;
83
          case '4': result = mRes.getString(R.string.solver_cube3_error4); break;
84
          case '5': result = mRes.getString(R.string.solver_cube3_error5); break;
85
          case '6': result = mRes.getString(R.string.solver_cube3_error6); break;
86
          case '7': result = mRes.getString(R.string.solver_cube3_error7); break;
87
          case '8': result = mRes.getString(R.string.solver_cube3_error8); break;
88
          case '9': result = mRes.getString(R.string.solver_cube3_error9); break;
89
          }
90

  
91
        solver.displayErrorDialog(result);
92
        }
93
      else
94
        {
95
        solver.setSolved(result);
84 96
        }
85

  
86
      solver.displayErrorDialog(result);
87 97
      }
88 98
    else
89 99
      {
90
      solver.setSolved(result);
100
      String color = mRes.getString(mColorID);
101
      result = mRes.getString(R.string.solver_cube3_error1,check,color);
102
      solver.displayErrorDialog(result);
91 103
      }
92 104
    }
93 105

  
......
128 140
    return -1;
129 141
    }
130 142

  
143
///////////////////////////////////////////////////////////////////////////////////////////////////
144

  
145
  private int checkPosition(String position)
146
    {
147
    int[] numColors = new int[6];
148
    int len = position.length();
149

  
150
    for(int i=0; i<len; i++)
151
      {
152
      char ch = position.charAt(i);
153

  
154
      switch(ch)
155
        {
156
        case 'R': numColors[0]++; break;
157
        case 'L': numColors[1]++; break;
158
        case 'U': numColors[2]++; break;
159
        case 'D': numColors[3]++; break;
160
        case 'F': numColors[4]++; break;
161
        case 'B': numColors[5]++; break;
162
        }
163
      }
164

  
165
    if( numColors[0]<9 ) { mColorID = R.string.color_yellow; return numColors[0]; }
166
    if( numColors[1]<9 ) { mColorID = R.string.color_white ; return numColors[1]; }
167
    if( numColors[2]<9 ) { mColorID = R.string.color_blue  ; return numColors[2]; }
168
    if( numColors[3]<9 ) { mColorID = R.string.color_green ; return numColors[3]; }
169
    if( numColors[4]<9 ) { mColorID = R.string.color_red   ; return numColors[4]; }
170
    if( numColors[5]<9 ) { mColorID = R.string.color_orange; return numColors[5]; }
171

  
172
    return -1;
173
    }
174

  
131 175
///////////////////////////////////////////////////////////////////////////////////////////////////
132 176
// order: Up --> Right --> Front --> Down --> Left --> Back
133 177
// (because the first implemented Solver - the two-phase Cube3 one - expects such order)
src/main/res/values-de/strings.xml
70 70

  
71 71
    <string name="solver_generic_error1">Löser für dieses Objekt und diese Größe noch nicht implementiert!</string>
72 72

  
73
    <string name="solver_cube3_error1">Es gibt nicht genau 9 Facelets jeder Farbe!</string>
73
    <string name="solver_cube3_error1">Es gibt nur %1$d %2$s Facelets.</string>
74 74
    <string name="solver_cube3_error2">Nicht alle 12 Kanten gibt es genau einmal!</string>
75 75
    <string name="solver_cube3_error3">Eine Kante muss umgedreht werden!</string>
76 76
    <string name="solver_cube3_error4">Nicht alle 8 Ecken gibt es genau einmal!</string>
......
80 80
    <string name="solver_cube3_error8">Zeitüberschreitung. Keine Lösung in 20 Sekunden gefunden!</string>
81 81
    <string name="solver_cube3_error9">Löser unterbrochen!</string>
82 82

  
83
    <string name="color_yellow">gelbe</string>
84
    <string name="color_white">weiße</string>
85
    <string name="color_blue">blaue</string>
86
    <string name="color_green">grüne</string>
87
    <string name="color_red">rote</string>
88
    <string name="color_orange">orange</string>
89

  
83 90
    <string name="ms_placeholder">%1$d ms</string>
84 91
    <string name="lv_placeholder">Level %1$d</string>
85 92
    <string name="tm_placeholder">%1$02d:%2$02d</string>
src/main/res/values-es/strings.xml
70 70

  
71 71
    <string name="solver_generic_error1">¡Aún no se implementado el solucionador para este objeto y tamaño!</string>
72 72

  
73
    <string name="solver_cube3_error1">¡No hay exactamente 9 facelets de cada color!</string>
73
    <string name="solver_cube3_error1">Solo hay %1$d facetas %2$s.</string>
74 74
    <string name="solver_cube3_error2">¡No todos los 12 bordes existen exactamente una vez!</string>
75 75
    <string name="solver_cube3_error3">¡Un borde tiene que voltearse!</string>
76 76
    <string name="solver_cube3_error4">¡No todas las 8 esquinas existen exactamente una vez!</string>
......
80 80
    <string name="solver_cube3_error8">¡Tiempo de espera agotado, no se encontró ninguna solución en 20 segundos!</string>
81 81
    <string name="solver_cube3_error9">¡Solucionador interrumpido!</string>
82 82

  
83
    <string name="color_yellow">amarillas</string>
84
    <string name="color_white">blancos</string>
85
    <string name="color_blue">azules</string>
86
    <string name="color_green">verdes</string>
87
    <string name="color_red">rojos</string>
88
    <string name="color_orange">naranjas</string>
89

  
83 90
    <string name="ms_placeholder">%1$d ms</string>
84 91
    <string name="lv_placeholder">Nivel %1$d</string>
85 92
    <string name="tm_placeholder">%1$02d:%2$02d</string>
src/main/res/values-fr/strings.xml
70 70

  
71 71
    <string name="solver_generic_error1">Solutionneur pour cet objet et cette taille non encore mis en place !</string>
72 72

  
73
    <string name="solver_cube3_error1">Il n\'y a pas exactement 9 facettes de chaque couleur !</string>
73
    <string name="solver_cube3_error1">Il n\'y a que %1$d facettes %2$s.</string>
74 74
    <string name="solver_cube3_error2">Les 12 arêtes n\'existent pas exactement une fois !</string>
75 75
    <string name="solver_cube3_error3">Une arête doit être inversée !</string>
76 76
    <string name="solver_cube3_error4">Les 8 coins n\'existent pas tous une seule fois !</string>
......
80 80
    <string name="solver_cube3_error8">Temps imparti, aucune solution trouvée en 20 secondes !</string>
81 81
    <string name="solver_cube3_error9">Solutionneur interrompu !</string>
82 82

  
83
    <string name="color_yellow">jaunes</string>
84
    <string name="color_white">blanches</string>
85
    <string name="color_blue">bleues</string>
86
    <string name="color_green">vertes</string>
87
    <string name="color_red">rouges</string>
88
    <string name="color_orange">orange</string>
89

  
83 90
    <string name="ms_placeholder">%1$d ms</string>
84 91
    <string name="lv_placeholder">Niveau %1$d</string>
85 92
    <string name="tm_placeholder">%1$02d:%2$02d</string>
src/main/res/values-ja/strings.xml
70 70

  
71 71
    <string name="solver_generic_error1">このオブジェクトとサイズのソルバーはまだ実装されていません!</string>
72 72

  
73
    <string name="solver_cube3_error1">各色には 9 つのフェイスレットはありません。</string>
73
    <string name="solver_cube3_error1">%2$s小顔は%1$dつだけ</string>
74 74
    <string name="solver_cube3_error2">12 のエッジすべてが 存在するわけではありません。</string>
75 75
    <string name="solver_cube3_error3">1 つのエッジを反転する必要があります!</string>
76 76
    <string name="solver_cube3_error4">8 つのコーナーすべてが存在するわけではありません!</string>
......
80 80
    <string name="solver_cube3_error8">タイムアウトです。20 秒では解答は見つかりません!</string>
81 81
    <string name="solver_cube3_error9">ソルバーが中断されました!</string>
82 82

  
83
    <string name="color_yellow">黄色い</string>
84
    <string name="color_white">白い</string>
85
    <string name="color_blue">青い</string>
86
    <string name="color_green">緑の</string>
87
    <string name="color_red">赤い</string>
88
    <string name="color_orange">オレンジ色の</string>
89

  
83 90
    <string name="ms_placeholder">%1$d ms</string>
84 91
    <string name="lv_placeholder">レベル %1$d</string>
85 92
    <string name="tm_placeholder">%1$02d:%2$02d</string>
src/main/res/values-ko/strings.xml
70 70

  
71 71
    <string name="solver_generic_error1">아직 구현되지 않은 이 개체 및 크기에 대한 해결사!</string>
72 72

  
73
    <string name="solver_cube3_error1">각 색상마다 정확히 9개의 페이스렛이 없습니다!</string>
73
    <string name="solver_cube3_error1">%2$s작은 얼굴은  %1$d개뿐입니다.</string>
74 74
    <string name="solver_cube3_error2">12개의 가장자리 모두가 정확하게 한 번 존재하지 않습니다!</string>
75 75
    <string name="solver_cube3_error3">한쪽 가장자리를 뒤집어야 합니다!</string>
76 76
    <string name="solver_cube3_error4">8개의 모서리 모두가 정확하게 한 번 존재하지 않습니다!</string>
......
80 80
    <string name="solver_cube3_error8">시간 초과, 20초 안에 해답이 발견되지 않았습니다!</string>
81 81
    <string name="solver_cube3_error9">해결사가 중단되었습니다!</string>
82 82

  
83
    <string name="color_yellow">노란색</string>
84
    <string name="color_white">하얀</string>
85
    <string name="color_blue">파란색</string>
86
    <string name="color_green">녹색의</string>
87
    <string name="color_red">빨간</string>
88
    <string name="color_orange">주황색</string>
89

  
83 90
    <string name="ms_placeholder">%1$d ms</string>
84 91
    <string name="lv_placeholder">레벨 %1$d</string>
85 92
    <string name="tm_placeholder">%1$02d:%2$02d</string>
src/main/res/values-pl/strings.xml
70 70

  
71 71
    <string name="solver_generic_error1">Rozwiązywacz takiego obiektu jest jeszcze nie zaimplementowany!</string>
72 72

  
73
    <string name="solver_cube3_error1">Nie ma dokładnie 9 ścian w każdym kolorze!</string>
73
    <string name="solver_cube3_error1">Jest tylko %1$d %2$s ścian.</string>
74 74
    <string name="solver_cube3_error2">Któraś z 12 krawędzi nie istnieje!</string>
75 75
    <string name="solver_cube3_error3">Jedna z krawędzi musi być odwrócona!</string>
76 76
    <string name="solver_cube3_error4">Jeden z 8 rogów nie istnieje!</string>
......
80 80
    <string name="solver_cube3_error8">Minęło 20 sekund i rozwiązanie nie zostało znalezione!</string>
81 81
    <string name="solver_cube3_error9">Rozwiązywacz przerwany!</string>
82 82

  
83
    <string name="color_yellow">żółtych</string>
84
    <string name="color_white">białych</string>
85
    <string name="color_blue">niebieskich</string>
86
    <string name="color_green">zielonych</string>
87
    <string name="color_red">czerwonych</string>
88
    <string name="color_orange">pomarańczowych</string>
89

  
83 90
    <string name="ms_placeholder">%1$d ms</string>
84 91
    <string name="lv_placeholder">Poziom %1$d</string>
85 92
    <string name="tm_placeholder">%1$02d:%2$02d</string>
src/main/res/values-ru/strings.xml
70 70

  
71 71
    <string name="solver_generic_error1">Решебника для этого объекта и размера еще нет!</string>
72 72

  
73
    <string name="solver_cube3_error1">Отсутствует точно 9 граней каждого цвета!</string>
73
    <string name="solver_cube3_error1">Всего %1$d %2$s граней!</string>
74 74
    <string name="solver_cube3_error2">Не все 12 ребер существуют в единичном экземпляре!</string>
75 75
    <string name="solver_cube3_error3">Надо перевернуть одно ребро!</string>
76 76
    <string name="solver_cube3_error4">Не все 8 углов существуют в единичном экземпляре!</string>
......
79 79
    <string name="solver_cube3_error7">Не существует решения для данного максимального числа ходов!</string>
80 80
    <string name="solver_cube3_error8">Время вышло: решение не найдено в течение 20 секунд!</string>
81 81
    <string name="solver_cube3_error9">Решебник прерван!</string>
82
]
83
    <string name="color_yellow">желтых</string>
84
    <string name="color_white">белых</string>
85
    <string name="color_blue">синих</string>
86
    <string name="color_green">зеленых</string>
87
    <string name="color_red">красных</string>
88
    <string name="color_orange">оранжевых</string>
82 89

  
83 90
    <string name="ms_placeholder">%1$d мс</string>
84 91
    <string name="lv_placeholder">Уровень %1$d</string>
src/main/res/values-zh-rCN/strings.xml
76 76

  
77 77
    <string name="solver_generic_error1">此对象和尺寸的求解器尚未实现!</string>
78 78

  
79
    <string name="solver_cube3_error1">每种颜色并非全有9个小面!</string>
79
    <string name="solver_cube3_error1">只有%1$d个%2$s小面</string>
80 80
    <string name="solver_cube3_error2">并非所有12条边都只存在一次!</string>
81 81
    <string name="solver_cube3_error3">一条边需要翻转!</string>
82 82
    <string name="solver_cube3_error4">并非所有8个角都只存在一次!</string>
......
86 86
    <string name="solver_cube3_error8">超时,20秒内未找到解决方案!</string>
87 87
    <string name="solver_cube3_error9">求解器中断!</string>
88 88

  
89
    <string name="color_yellow">黄色的</string>
90
    <string name="color_white">白色的</string>
91
    <string name="color_blue">蓝色的</string>
92
    <string name="color_green">绿色的</string>
93
    <string name="color_red">红色的</string>
94
    <string name="color_orange">橙色的</string>
95

  
89 96
    <string name="ms_placeholder">%1$d 毫秒</string>
90 97
    <string name="lv_placeholder">级别 %1$d</string>
91 98
    <string name="tm_placeholder">%1$02d:%2$02d</string>
src/main/res/values-zh-rTW/strings.xml
70 70

  
71 71
    <string name="solver_generic_error1">此對象和尺寸的求解器尚未實現!</string>
72 72

  
73
    <string name="solver_cube3_error1">每種颜色並非全有9個小面!</string>
73
    <string name="solver_cube3_error1">只有%1$d個%2$s小臉</string>
74 74
    <string name="solver_cube3_error2">並非所有12條邊都只存在一次!</string>
75 75
    <string name="solver_cube3_error3">一條邊需要翻轉!</string>
76 76
    <string name="solver_cube3_error4">並非所有8個角都只存在一次!</string>
......
80 80
    <string name="solver_cube3_error8">超時,20秒内未找到解决方案!</string>
81 81
    <string name="solver_cube3_error9">求解器中斷!</string>
82 82

  
83
    <string name="color_yellow">黃色的</string>
84
    <string name="color_white">白色的</string>
85
    <string name="color_blue">藍色的</string>
86
    <string name="color_green">綠色的</string>
87
    <string name="color_red">紅色的</string>
88
    <string name="color_orange">橙色的</string>
89

  
83 90
    <string name="ms_placeholder">%1$d 毫秒</string>
84 91
    <string name="lv_placeholder">級別 %1$d</string>
85 92
    <string name="tm_placeholder">%1$02d:%2$02d</string>
src/main/res/values/strings.xml
90 90
    <string name="opengl_error_text" translatable="false">This device does not support OpenGL 3.0</string>
91 91

  
92 92
    <string name="solver_generic_error1">Solver for this object and size not implemented yet!</string>
93
    <string name="solver_cube3_error1">There are not exactly 9 facelets of each color!</string>
93
    <string name="solver_cube3_error1">There are only %1$d %2$s facelets.</string>
94 94
    <string name="solver_cube3_error2">Not all 12 edges exist exactly once!</string>
95 95
    <string name="solver_cube3_error3">One edge has to be flipped!</string>
96 96
    <string name="solver_cube3_error4">Not all 8 corners exist exactly once!</string>
......
100 100
    <string name="solver_cube3_error8">Timeout, no solution found in 20 seconds!</string>
101 101
    <string name="solver_cube3_error9">Solver interrupted!</string>
102 102

  
103
    <string name="color_yellow">yellow</string>
104
    <string name="color_white">white</string>
105
    <string name="color_blue">blue</string>
106
    <string name="color_green">green</string>
107
    <string name="color_red">red</string>
108
    <string name="color_orange">orange</string>
109

  
103 110
    <string name="ms_placeholder">%1$d ms</string>
104 111
    <string name="lv_placeholder">Level %1$d</string>
105 112
    <string name="tm_placeholder">%1$02d:%2$02d</string>

Also available in: Unified diff