Project

General

Profile

« Previous | Next » 

Revision 742401b4

Added by Leszek Koltunski about 1 year ago

Dino6 solver: skeleton tablebase class.

View differences:

src/main/java/org/distorted/solvers/SolverDino6.java
15 15
import org.distorted.objectlib.main.ObjectSignatures;
16 16
import org.distorted.objectlib.main.TwistyObject;
17 17
import org.distorted.objectlib.tablebases.ImplementedTablebasesList;
18
import org.distorted.objectlib.tablebases.TBDino6;
19
import org.distorted.objectlib.tablebases.TablebaseHelpers;
18 20
import org.distorted.objectlib.tablebases.TablebasesAbstract;
19 21

  
20 22
///////////////////////////////////////////////////////////////////////////////////////////////////
......
26 28
  private static final int ERROR_EDGE_TWISTED        = -3;
27 29
  private static final int ERROR_EDGE_MONOCHROMATIC  = -4;
28 30
  private static final int ERROR_EDGE_TWICE          = -5;
31
  private static final int ERROR_TWO_EDGES           = -6;
29 32

  
30 33
  int[][] EDGE_MAP = {
31 34
                      {4,2},{0,4},{4,3},{1,4},
......
275 278
    return 0;
276 279
    }
277 280

  
281
///////////////////////////////////////////////////////////////////////////////////////////////////
282

  
283
  private int getPerm(int face0, int face1, int[][] edges)
284
    {
285
    int c0=mFaceColors[face0];
286
    int c1=mFaceColors[face1];
287

  
288
    for(int i=0; i<12; i++)
289
      {
290
      int[] edge = edges[i];
291
      if( edge[0]==c0 && edge[1]==c1 ) return i;
292
      }
293

  
294
    return -1;
295
    }
296

  
297
///////////////////////////////////////////////////////////////////////////////////////////////////
298

  
299
  private int computePermutation(int[][] edges, int[] perm)
300
    {
301
    for(int i=0; i<12; i++)
302
      {
303
      int[] map = EDGE_MAP[i];
304
      int m1 = map[0];
305
      int m2 = map[1];
306
      perm[i] = getPerm(m1,m2,edges);
307
      }
308

  
309
    return 0;
310
    }
311

  
278 312
///////////////////////////////////////////////////////////////////////////////////////////////////
279 313

  
280 314
  public int tablebaseIndex(TwistyObject object)
......
285 319
    int result1 = figureOutFaceColors(edges);
286 320
    if( result1<0 ) return result1;
287 321

  
288
for(int i=0; i<6; i++)
289
  {
290
  android.util.Log.e("D", "face "+i+" : "+mFaceColors[i]);
291
  }
292

  
293 322
    int result2 = checkAllPresent(edges);
294 323
    if( result2<0 ) return result2;
295 324

  
296 325
    int result3 = checkTwist(edges);
297 326
    if( result3<0 ) return result3;
298 327

  
299
    return 0;
328
    int[] perm = new int[12];
329
    int result4 = computePermutation(edges,perm);
330
    if( result4<0 ) return result4;
331

  
332
    if( !TablebaseHelpers.permutationIsEven(perm) ) return ERROR_TWO_EDGES;
333

  
334
    return TBDino6.getIndexFromPerm(perm);
300 335
    }
301 336

  
302 337
///////////////////////////////////////////////////////////////////////////////////////////////////
......
394 429
      case ERROR_EDGE_MONOCHROMATIC: return edgeMonoError(res,mErrorColor1);
395 430
      case ERROR_EDGE_TWICE        : return edgeTwiceError(res,mErrorColor1,mErrorColor2);
396 431
      case ERROR_EDGE_CANNOT       : return res.getString(R.string.solver_generic_edges_cannot);
432
      case ERROR_TWO_EDGES         : return res.getString(R.string.solver_generic_two_edges);
397 433
      }
398 434

  
399 435
    return null;

Also available in: Unified diff