Project

General

Profile

« Previous | Next » 

Revision 20d7d940

Added by Leszek Koltunski 12 months ago

speedup

View differences:

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

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

  
12
import org.distorted.library.helpers.QuatHelper;
12 13
import org.distorted.library.type.Static3D;
13 14
import org.distorted.objectlib.R;
14 15
import org.distorted.objectlib.helpers.OperatingSystemInterface;
......
197 198
    return new boolean[][] { {true,false,true},{false,true},{true,true,false} };
198 199
    }
199 200

  
201
///////////////////////////////////////////////////////////////////////////////////////////////////
202
// purely for speedup
203

  
204
  @Override
205
  int computeRow(float[] pos, int quat, int axisIndex)
206
    {
207
    QuatHelper.rotateVectorByQuat(mTmp,pos[0],pos[1],pos[2],1.0f,mQuats[quat]);
208

  
209
    switch(axisIndex)
210
      {
211
      case 0: if( mTmp[0]<-0.5f ) return 1;
212
              if( mTmp[0]< 0.5f ) return 2;
213
              return 4;
214
      case 1: return (mTmp[1]<0 ? 1:2);
215
      case 2: if( mTmp[2]<-0.5f ) return 1;
216
              if( mTmp[2]< 0.5f ) return 2;
217
              return 4;
218
      }
219

  
220
    return 0;
221
    }
222

  
200 223
///////////////////////////////////////////////////////////////////////////////////////////////////
201 224
// we map the move (axis=2, middle layer) to move (axis=2,both middle and back layers).
202 225
// this way we can imitate move of the front layer (which we do not want to move because
src/main/java/org/distorted/objectlib/tablebases/TablebasesAbstract.java
30 30
  private final int[][] mAngles;
31 31
  private final int[] mNumLayers;
32 32
  private final int mNumQuats;
33
  private final Static4D[] mQuats;
34 33
  private final float[][] mCuts;
35 34
  private final int[] mNumCuts;
36 35

  
......
40 39
  Tablebase mTablebase;
41 40
  boolean mInitialized;
42 41

  
42
  final Static4D[] mQuats;
43 43
  final int mScalingFactor;
44 44
  final int mNumAxis;
45 45
  final float[][] mPosition;
......
47 47
  final int mNumCubits;
48 48
  final boolean[][] mRotatable;
49 49

  
50
  private static final float[] mTmp = new float[4];
50
  static final float[] mTmp = new float[4];
51 51

  
52 52
///////////////////////////////////////////////////////////////////////////////////////////////////
53 53

  
......
143 143
    float axisX = axis.get0();
144 144
    float axisY = axis.get1();
145 145
    float axisZ = axis.get2();
146
    float casted, xoff=0, yoff=0, zoff=0;
146
    float casted;
147 147
    Static4D q = mQuats[quat];
148 148

  
149 149
    for(int i=0; i<len; i++)
150 150
      {
151 151
      QuatHelper.rotateVectorByQuat(mTmp,pos[3*i],pos[3*i+1],pos[3*i+2],1.0f,q);
152
      casted = (mTmp[0]+xoff)*axisX + (mTmp[1]+yoff)*axisY + (mTmp[2]+zoff)*axisZ;
152
      casted = mTmp[0]*axisX + mTmp[1]*axisY + mTmp[2]*axisZ;
153 153
      ret |= computeSingleRow(axisIndex,casted);
154 154
      }
155 155

  
src/main/java/org/distorted/objectlib/tablebases/TablebasesPruning.java
503 503
      }
504 504
    else
505 505
      {
506
      if( osi!=null ) osi.reportError("error traversing mid Tables: "+index);
506
      osi.reportError("error traversing mid Tables: "+index);
507 507
      return null;
508 508
      }
509 509
    int[][] jump2Moves = jumpToSolved(index,mLowestMid-1,lastA,lastR);
510 510
    if( jump2Moves==null )
511 511
      {
512
      if( osi!=null ) osi.reportError("2 error jumping to Solved: "+index);
512
      osi.reportError("2 error jumping to Solved: "+index);
513 513
      return null;
514 514
      }
515 515
    return concatenateMoves(highMoves,jump1Moves,midMoves,jump2Moves);

Also available in: Unified diff