Project

General

Profile

« Previous | Next » 

Revision f32c546d

Added by Leszek Koltunski about 1 year ago

Pyraminx solver: tablebase working now (tipless, tips to be added in the SolverPyraminx class)

View differences:

src/main/java/org/distorted/objectlib/tablebases/TablebasesAbstract.java
256 256
              int currQuat = tmpQuats[cubit];
257 257
              int newQuat = getMultQuat(quat,currQuat);
258 258
              tmpQuats[cubit] = newQuat;
259

  
260
if( index==0 && ax==2 && layer==1 && angle==2 )
261
  {
262
  android.util.Log.e("D","cubit "+cubit+" belongs, oldQ="+currQuat+" quat="+quat+" new: "+newQuat);
263
  }
264 259
              }
265 260

  
266
if( tmpQuats[4]==0 &&  tmpQuats[5]==1 && tmpQuats[6]==4 && tmpQuats[7]==3 && tmpQuats[8]==10 && tmpQuats[9]==9 )
267
  {
268
  android.util.Log.e("D","index="+index+" level="+level+" ax="+ax+" layer="+layer+" angle="+angle);
269
  android.util.Log.e("D", quats[4]+" "+quats[5]+" "+quats[6]+" "+quats[7]+" "+quats[8]+" "+quats[9]);
270
  }
271

  
272 261
          int childIndex = getIndex(tmpQuats);
273 262
          if( mTablebase.insertUnpacked(childIndex,newLevel) ) ret++;
274 263
          }
src/main/java/org/distorted/objectlib/tablebases/TablebasesPyraminx.java
28 28
          { 4, 8},
29 29
          { 2, 6},
30 30
          { 3, 5},
31
          { 9,11}
31
          {11, 9}
32 32
      };
33 33

  
34 34
///////////////////////////////////////////////////////////////////////////////////////////////////
......
150 150

  
151 151
  private void getEdgeQuats(int twist, int[] perm, int[] output)
152 152
    {
153
    for(int i=0; i<6; i++)
153
    int totalTwist = 0;
154

  
155
    for(int i=0; i<5; i++)
154 156
      {
155 157
      int p = perm[i];
156
      int t = twist%2;
158
      int t = (twist%2);
157 159
      twist/=2;
158 160
      output[i+4] = EDGE_QUATS[p][t];
161

  
162
      totalTwist += t;
159 163
      }
164

  
165
    int p = perm[5];
166
    int t = (totalTwist%2)==0 ? 0:1;
167
    output[9] = EDGE_QUATS[p][t];
160 168
    }
161 169

  
162 170
///////////////////////////////////////////////////////////////////////////////////////////////////
......
218 226

  
219 227
///////////////////////////////////////////////////////////////////////////////////////////////////
220 228

  
221
  int[] getQuats(int index)
229
  public int[] getQuats(int index)
222 230
    {
223 231
    int vertexTwist = (index%81);
224 232
    index /= 81;
......
229 237

  
230 238
    getVertexQuats(vertexTwist,quats);
231 239
    int[] permutation = new int[6];
232
    TablebaseHelpers.getPermutationFromNum(permutation,6,perm_num);
240
    TablebaseHelpers.getEvenPermutationFromNum(permutation,6,perm_num);
233 241
    getEdgeQuats(edgeTwist,permutation,quats);
234 242

  
235 243
    return quats;
......
237 245

  
238 246
///////////////////////////////////////////////////////////////////////////////////////////////////
239 247

  
240
  int getIndex(int[] quats)
248
  public int getIndex(int[] quats)
241 249
    {
242 250
    int vertexTwist = getVertexTwist(quats);
243 251
    int[] permutation = new int[6];
......
248 256
    int edgeTwist = twist[0]+ 2*(twist[1]+ 2*(twist[2]+ 2*(twist[3]+ 2*twist[4])));
249 257
    int perm_num = TablebaseHelpers.computeEvenPermutationNum(permutation);
250 258

  
251
int ret = vertexTwist + 81*(edgeTwist + 32*perm_num);
252

  
253
if( ret<0 || ret>=933120 )
254
  {
255
  android.util.Log.e("D", "vertexTwist="+vertexTwist+" edgeTwist="+edgeTwist+" perm_num="+perm_num);
256
  android.util.Log.e("D", "perm: "+permutation[0]+" "+permutation[1]+" "+permutation[2]+" "+permutation[3]+" "+permutation[4]+" "+permutation[5]);
257
  android.util.Log.e("D", "quat: "+quats[4]+" "+quats[5]+" "+quats[6]+" "+quats[7]+" "+quats[8]+" "+quats[9]);
258
  }
259

  
260 259
    return vertexTwist + 81*(edgeTwist + 32*perm_num);
261 260
    }
262 261
}  

Also available in: Unified diff