Project

General

Profile

« Previous | Next » 

Revision 6d637f71

Added by Leszek Koltunski about 1 year ago

Move corner orientation from SolverPyraminx to TablebasesPyraminx (we'll need it for better-looking tablebases scrambling)

View differences:

src/main/java/org/distorted/objectlib/tablebases/TablebasesPyraminx.java
105 105

  
106 106
///////////////////////////////////////////////////////////////////////////////////////////////////
107 107
// specifically for the tablebase
108
///////////////////////////////////////////////////////////////////////////////////////////////////
109

  
110
  private void addMove(int[] move, int axis, int twist)
111
    {
112
    move[0] = axis;
113
    move[1] = (1<<2);
114
    move[2] = (twist==2 ? -1:twist);
115
    }
116

  
117
///////////////////////////////////////////////////////////////////////////////////////////////////
118

  
119
  private int[][] constructTipMoves(int[] twist)
120
    {
121
    int total = 0;
122

  
123
    for(int i=0; i<4; i++)
124
      if( twist[i]!=0 ) total++;
125

  
126
    if( total>0 )
127
      {
128
      int[][] moves = new int[total][3];
129

  
130
      int index=0;
131
      if( twist[0]!=0 ) { addMove(moves[index],1,twist[0]); index++; }
132
      if( twist[1]!=0 ) { addMove(moves[index],0,twist[1]); index++; }
133
      if( twist[2]!=0 ) { addMove(moves[index],3,twist[2]); index++; }
134
      if( twist[3]!=0 ) { addMove(moves[index],2,twist[3]);          }
135

  
136
      return moves;
137
      }
138

  
139
    return null;
140
    }
141

  
142
///////////////////////////////////////////////////////////////////////////////////////////////////
143
// extra = cornerTips
144

  
145
  @Override
146
  int[][] extraInfo(int[][] moves, int[] extra)
147
    {
148
    int[][] tipMoves = constructTipMoves(extra);
149

  
150
    int len1 = (   moves==null ? 0:   moves.length);
151
    int len2 = (tipMoves==null ? 0:tipMoves.length);
152

  
153
    int[][] ret = new int[len1+len2][3];
154

  
155
    if( len1>0 ) System.arraycopy(   moves, 0, ret,    0, len1);
156
    if( len2>0 ) System.arraycopy(tipMoves, 0, ret, len1, len2);
157

  
158
    return ret;
159
    }
160

  
108 161
///////////////////////////////////////////////////////////////////////////////////////////////////
109 162

  
110 163
  int getSize()
......
114 167

  
115 168
///////////////////////////////////////////////////////////////////////////////////////////////////
116 169

  
117
 int getMinScramble()
170
  int getMinScramble()
118 171
    {
119 172
    return 9;
120 173
    }

Also available in: Unified diff