Project

General

Profile

« Previous | Next » 

Revision a76bb8f6

Added by Leszek Koltunski about 1 year ago

Dino solvers: unroll moves!

View differences:

src/main/java/org/distorted/objectlib/tablebases/TBDino4.java
9 9

  
10 10
package org.distorted.objectlib.tablebases;
11 11

  
12
import static org.distorted.objectlib.main.TwistyObject.SQ3;
13

  
14 12
import android.content.res.Resources;
15 13

  
16
import org.distorted.library.type.Static3D;
17 14
import org.distorted.objectlib.R;
18 15

  
19 16
///////////////////////////////////////////////////////////////////////////////////////////////////
20 17

  
21
public class TBDino4 extends TablebasesAbstract
18
public class TBDino4 extends TBDino
22 19
{
23 20
  private static final int[][] SAME = {{0,3,7},{1,2,5},{4,8,9},{6,10,11}};
24
  private static final int SOLVED1 =  6237;  // part 011021302233
25
  private static final int SOLVED2 = 10837;  // part 001102133223
26
  private int[][] mAngles;
21
  private static final int SOLVED1 =  6237;  // partition 011021302233
22
  private static final int SOLVED2 = 10837;  // partition 001102133223
27 23

  
28 24
///////////////////////////////////////////////////////////////////////////////////////////////////
29 25

  
......
36 32

  
37 33
  public TBDino4(Resources res)
38 34
    {
39
    super(res, R.raw.din4_3_tablebase);
40
    }
41

  
42
///////////////////////////////////////////////////////////////////////////////////////////////////
43

  
44
  int[][] getBasicAngles()
45
    {
46
    if( mAngles==null )
47
      {
48
      int[] tmp = {3,3,3};
49
      mAngles = new int[][] { tmp,tmp,tmp,tmp };
50
      }
51

  
52
    return mAngles;
53
    }
54

  
55
///////////////////////////////////////////////////////////////////////////////////////////////////
56

  
57
  Static3D[] getRotationAxis()
58
    {
59
    return new Static3D[]
60
         {
61
           new Static3D( SQ3/3, SQ3/3, SQ3/3),
62
           new Static3D(-SQ3/3,-SQ3/3, SQ3/3),
63
           new Static3D(-SQ3/3, SQ3/3,-SQ3/3),
64
           new Static3D( SQ3/3,-SQ3/3,-SQ3/3),
65
         };
66
    }
67

  
68
///////////////////////////////////////////////////////////////////////////////////////////////////
69

  
70
  float[][] getPosition()
71
    {
72
    return new float[][]
73
         {
74
             { 0.0f, 1.5f, 1.5f },
75
             { 1.5f, 0.0f, 1.5f },
76
             { 0.0f,-1.5f, 1.5f },
77
             {-1.5f, 0.0f, 1.5f },
78
             { 1.5f, 1.5f, 0.0f },
79
             { 1.5f,-1.5f, 0.0f },
80
             {-1.5f,-1.5f, 0.0f },
81
             {-1.5f, 1.5f, 0.0f },
82
             { 0.0f, 1.5f,-1.5f },
83
             { 1.5f, 0.0f,-1.5f },
84
             { 0.0f,-1.5f,-1.5f },
85
             {-1.5f, 0.0f,-1.5f }
86
         };
87
    }
88

  
89
///////////////////////////////////////////////////////////////////////////////////////////////////
90

  
91
  float[][] getCuts()
92
    {
93
    float[] cut = new float[] { -SQ3/3, SQ3/3 };
94
    return new float[][] { cut,cut,cut,cut };
95
    }
96

  
97
///////////////////////////////////////////////////////////////////////////////////////////////////
98
// exclude the middle layer
99

  
100
  boolean[][] getRotatable()
101
    {
102
    boolean[] tmp = {true,false,true};
103
    return new boolean[][] { tmp,tmp,tmp,tmp };
35
    super(res, new int[] {R.raw.din4_3_pruning2,R.raw.din4_3_pruning3}, new int[] {R.raw.din4_3_pruning7});
104 36
    }
105 37

  
106 38
///////////////////////////////////////////////////////////////////////////////////////////////////
......
124 56
    }
125 57

  
126 58
///////////////////////////////////////////////////////////////////////////////////////////////////
127
// we can never really move the top-front edge, because if we do so, we would also rotate the
128
// rotation axis themselves! (see getIndex() where the cubit quats are normalized so that quat[0]
129
// - i.e. the front-top edge - is always 0).
130
// That's why map the moves (0,2,X) to (0,0&1,-X) and (3,0,X) to (3,1&2,-X)
59
// 15408 really (see https://www.jaapsch.net/puzzles/dinocube.htm)
60
// Here 15400 because we equal positions where colors are simply swapped (those are the same with
61
// respect to distance to the 2 solved positions) so there are (11 choose 2)*(8 choose 2)*(5 choose 2)
62
// = 55*28*10 = 15400 possibilities.
63
// We do not pack those tightly, some positions in the same orbit (by Burnside lemma) have 3 different
64
// indices.
131 65

  
132
  @Override
133
  int[] newMove(int axis, int layer, int angle)
66
  int getSize()
134 67
    {
135
    if( axis==0 && layer==2 ) return new int[] { axis, 3, angle==1 ? 1:-1};
136
    if( axis==3 && layer==0 ) return new int[] { axis, 6, angle==1 ? 1:-1};
137

  
138
    int maxAngle = mAngles[axis][layer];
139
    angle = maxAngle-angle;
140
    if( angle> 0.5f*maxAngle ) angle -= maxAngle;
141
    return new int[] { axis, (1<<layer), angle };
68
    return 15400;
142 69
    }
143 70

  
144 71
///////////////////////////////////////////////////////////////////////////////////////////////////
145 72

  
146
  @Override
147
  void convertMoves(int[][] moves)
73
  int getMinScramble()
148 74
    {
149
    for(int[] move : moves )
150
      {
151
      int[] newMove = newMove(move[0],move[1],move[2]);
75
    return 5;
76
    }
152 77

  
153
      move[0] = newMove[0];
154
      move[1] = newMove[1];
155
      move[2] = newMove[2];
156
      }
78
///////////////////////////////////////////////////////////////////////////////////////////////////
79

  
80
  int[] getMidPruningLevels()
81
    {
82
    return new int[] {2,3};
157 83
    }
158 84

  
159 85
///////////////////////////////////////////////////////////////////////////////////////////////////
160
// 15408 really (see https://www.jaapsch.net/puzzles/dinocube.htm)
161
// Here 15400 because we equal positions where colors are simply swapped (those are the same with
162
// respect to distance to the 2 solved positions) so there are (11 choose 2)*(8 choose 2)*(5 choose 2)
163
// = 55*28*10 = 15400 possibilities.
164
// We do not pack those tightly, some positions in the same orbit (by Burnside lemma) have 3 different
165
// indices.
166 86

  
167
  int getSize()
87
  int[] getHighPruningLevels()
168 88
    {
169
    return 15400;
89
    return new int[] {7};
170 90
    }
171 91

  
172 92
///////////////////////////////////////////////////////////////////////////////////////////////////
173 93

  
174
  int getMinScramble()
94
  int getGodsNumber()
175 95
    {
176
    return 5;
96
    return 7;
177 97
    }
178 98

  
179 99
///////////////////////////////////////////////////////////////////////////////////////////////////
......
340 260
    return part;
341 261
    }
342 262

  
343
///////////////////////////////////////////////////////////////////////////////////////////////////
344
// we rotate the whole thing so that quat[0] is always 0.
345

  
346
  private void normalizeQuats(int[] quats)
347
    {
348
    if( quats[0]!=0 )
349
      {
350
      int inverted = getInvertedQuat(quats[0]);
351
      quats[0] = 0;
352

  
353
      for(int i=1; i<12; i++)
354
        {
355
        int index = quats[i];
356
        quats[i] = getMultQuat(inverted,index);
357
        }
358
      }
359
    }
360

  
361 263
///////////////////////////////////////////////////////////////////////////////////////////////////
362 264

  
363 265
  int[] getQuats(int index)

Also available in: Unified diff