Project

General

Profile

« Previous | Next » 

Revision ca4a3a68

Added by Leszek Koltunski 12 months ago

Algorithms now have their 'layers' in bitmap form.

We have to update all object JSON files.

View differences:

src/main/java/org/distorted/objectlib/objects/TwistyBandagedCuboid.java
285 285
      {
286 286
      return new int[][]
287 287
          {
288
              { 0,0,-1 }, { 0,0, 1 }, { 0,0, 2 }, { 0,1,-1 }, { 0,1, 1 }, { 0,1, 2 },  //  0-5 : L
289
              { 0,2,-1 }, { 0,2, 1 }, { 0,2, 2 }, { 0,3,-1 }, { 0,3, 1 }, { 0,3, 2 },  //  6-11: R
290
              { 1,0,-1 }, { 1,0, 1 }, { 1,0, 2 }, { 1,1,-1 }, { 1,1, 1 }, { 1,1, 2 },  // 12-17: D
291
              { 1,2,-1 }, { 1,2, 1 }, { 1,2, 2 }, { 1,3,-1 }, { 1,3, 1 }, { 1,3, 2 },  // 18-23: U
292
              { 2,0,-1 }, { 2,0, 1 }, { 2,0, 2 }, { 2,1,-1 }, { 2,1, 1 }, { 2,1, 2 },  // 24-29: B
293
              { 2,2,-1 }, { 2,2, 1 }, { 2,2, 2 }, { 2,3,-1 }, { 2,3, 1 }, { 2,3, 2 },  // 30-35: F
294

  
295
              { 1,3,1, 2,0,2 },  // 36: BEG->R
296
              { 1,0,1, 2,0,2 },  // 37: BEG->L
297
              { 2,3,1, 0,3,2 },  // 38: BEG->D
298
              { 2,0,1, 0,3,2 },  // 39: BEG->U
299
              { 0,3,1, 1,3,2 },  // 40: BEG->B
300
              { 0,0,1, 1,3,2 },  // 41: BEG->F
301

  
302
              { 1,0,-1, 0,3,2, 2,0,-1 }, // 42: R->D
303
              { 1,3, 1, 0,3,2, 2,3, 1 }, // 43: R->U
304
              { 2,0, 1, 0,3,2, 1,0, 1 }, // 44: R->B
305
              { 2,3,-1, 0,3,2, 1,3,-1 }, // 45: R->F
306

  
307
              { 1,0,-1, 0,0,2, 2,3, 1 }, // 46: L->D
308
              { 1,3, 1, 0,0,2, 2,0,-1 }, // 47: L->U
309
              { 2,0, 1, 0,0,2, 1,3,-1 }, // 48: L->B
310
              { 2,3,-1, 0,0,2, 1,0, 1 }, // 49: L->F
311

  
312
              { 0,3,-1, 1,0,2, 2,0, 1 }, // 50: D->R
313
              { 0,0, 1, 1,0,2, 2,3,-1 }, // 51: D->L
314
              { 2,0,-1, 1,0,2, 0,3, 1 }, // 52: D->B
315
              { 2,3, 1, 1,0,2, 0,0,-1 }, // 53: D->F
316

  
317
              { 0,3,-1, 1,3,2, 2,3,-1 }, // 54: U->R
318
              { 0,0, 1, 1,3,2, 2,0, 1 }, // 55: U->L
319
              { 2,0,-1, 1,3,2, 0,0,-1 }, // 56: U->B
320
              { 2,3, 1, 1,3,2, 0,3, 1 }, // 57: U->F
321

  
322
              { 0,3, 1, 2,0,2, 1,0,-1 }, // 58: B->R
323
              { 0,0,-1, 2,0,2, 1,3, 1 }, // 59: B->L
324
              { 1,0, 1, 2,0,2, 0,3,-1 }, // 60: B->D
325
              { 1,3,-1, 2,0,2, 0,0, 1 }, // 61: B->U
326

  
327
              { 0,3, 1, 2,3,2, 1,3, 1 }, // 62: F->R
328
              { 0,0,-1, 2,3,2, 1,0,-1 }, // 63: F->L
329
              { 1,0, 1, 2,3,2, 0,0, 1 }, // 64: F->D
330
              { 1,3,-1, 2,3,2, 0,3,-1 }, // 65: F->U
288
              { 0,1,-1 }, { 0,1, 1 }, { 0,1, 2 }, { 0,2,-1 }, { 0,2, 1 }, { 0,2, 2 },  //  0-5 : L
289
              { 0,4,-1 }, { 0,4, 1 }, { 0,4, 2 }, { 0,8,-1 }, { 0,8, 1 }, { 0,8, 2 },  //  6-11: R
290
              { 1,1,-1 }, { 1,1, 1 }, { 1,1, 2 }, { 1,2,-1 }, { 1,2, 1 }, { 1,2, 2 },  // 12-17: D
291
              { 1,4,-1 }, { 1,4, 1 }, { 1,4, 2 }, { 1,8,-1 }, { 1,8, 1 }, { 1,8, 2 },  // 18-23: U
292
              { 2,1,-1 }, { 2,1, 1 }, { 2,1, 2 }, { 2,2,-1 }, { 2,2, 1 }, { 2,2, 2 },  // 24-29: B
293
              { 2,4,-1 }, { 2,4, 1 }, { 2,4, 2 }, { 2,8,-1 }, { 2,8, 1 }, { 2,8, 2 },  // 30-35: F
294

  
295
              { 1,8,1, 2,1,2 },  // 36: BEG->R
296
              { 1,1,1, 2,1,2 },  // 37: BEG->L
297
              { 2,8,1, 0,8,2 },  // 38: BEG->D
298
              { 2,1,1, 0,8,2 },  // 39: BEG->U
299
              { 0,8,1, 1,8,2 },  // 40: BEG->B
300
              { 0,1,1, 1,8,2 },  // 41: BEG->F
301

  
302
              { 1,1,-1, 0,8,2, 2,1,-1 }, // 42: R->D
303
              { 1,8, 1, 0,8,2, 2,8, 1 }, // 43: R->U
304
              { 2,1, 1, 0,8,2, 1,1, 1 }, // 44: R->B
305
              { 2,8,-1, 0,8,2, 1,8,-1 }, // 45: R->F
306

  
307
              { 1,1,-1, 0,1,2, 2,8, 1 }, // 46: L->D
308
              { 1,8, 1, 0,1,2, 2,1,-1 }, // 47: L->U
309
              { 2,1, 1, 0,1,2, 1,8,-1 }, // 48: L->B
310
              { 2,8,-1, 0,1,2, 1,1, 1 }, // 49: L->F
311

  
312
              { 0,8,-1, 1,1,2, 2,1, 1 }, // 50: D->R
313
              { 0,1, 1, 1,1,2, 2,8,-1 }, // 51: D->L
314
              { 2,1,-1, 1,1,2, 0,8, 1 }, // 52: D->B
315
              { 2,8, 1, 1,1,2, 0,1,-1 }, // 53: D->F
316

  
317
              { 0,8,-1, 1,8,2, 2,8,-1 }, // 54: U->R
318
              { 0,1, 1, 1,8,2, 2,1, 1 }, // 55: U->L
319
              { 2,1,-1, 1,8,2, 0,1,-1 }, // 56: U->B
320
              { 2,8, 1, 1,8,2, 0,8, 1 }, // 57: U->F
321

  
322
              { 0,8, 1, 2,1,2, 1,1,-1 }, // 58: B->R
323
              { 0,1,-1, 2,1,2, 1,8, 1 }, // 59: B->L
324
              { 1,1, 1, 2,1,2, 0,8,-1 }, // 60: B->D
325
              { 1,8,-1, 2,1,2, 0,1, 1 }, // 61: B->U
326

  
327
              { 0,8, 1, 2,8,2, 1,8, 1 }, // 62: F->R
328
              { 0,1,-1, 2,8,2, 1,1,-1 }, // 63: F->L
329
              { 1,1, 1, 2,8,2, 0,1, 1 }, // 64: F->D
330
              { 1,8,-1, 2,8,2, 0,8,-1 }, // 65: F->U
331 331
          };
332 332
      }
333 333
    else
src/main/java/org/distorted/objectlib/objects/TwistyCamouflage.java
22 22
import org.distorted.objectlib.main.InitData;
23 23
import org.distorted.objectlib.main.ObjectSignatures;
24 24
import org.distorted.objectlib.main.ObjectType;
25
import org.distorted.objectlib.scrambling.ObjectScrambler;
26 25

  
27 26
///////////////////////////////////////////////////////////////////////////////////////////////////
28 27

  
......
156 155
    return new int[][]
157 156
      {
158 157
        // VTS' algorithm1: ('swap 2 edges and 2 pairs of centers')
159
        {2, 1, 1,  1, 0, 1,  0, 2, 1,  1, 0,-1,  0, 2,-1,
160
         1, 0, 1,  0, 2, 1,  1, 0,-1,  0, 2,-1,  2, 1,-1,
161
         0, 2, 1,  1, 0, 1,  0, 2,-1,  1, 0,-1,  0, 2, 1,
162
         1, 0, 1,  0, 2,-1,  1, 0,-1,  0, 2, 1,  0, 3, 1,
163
         1, 0, 2,  2, 0, 1,  1, 0,-2,  2, 0,-1,  1, 0, 2,
164
         0, 2,-1,  2, 1, 1,  0, 2, 1,  1, 0, 2,  2, 0, 1,
165
         1, 0,-2,  2, 0,-1,  1, 0, 2,  0, 2,-1,  2, 1,-2},
158
        {2, 2, 1,  1, 1, 1,  0, 4, 1,  1, 1,-1,  0, 4,-1,
159
         1, 1, 1,  0, 4, 1,  1, 1,-1,  0, 4,-1,  2, 2,-1,
160
         0, 4, 1,  1, 1, 1,  0, 4,-1,  1, 1,-1,  0, 4, 1,
161
         1, 1, 1,  0, 4,-1,  1, 1,-1,  0, 4, 1,  0, 8, 1,
162
         1, 1, 2,  2, 1, 1,  1, 1,-2,  2, 1,-1,  1, 1, 2,
163
         0, 4,-1,  2, 2, 1,  0, 4, 1,  1, 1, 2,  2, 1, 1,
164
         1, 1,-2,  2, 1,-1,  1, 1, 2,  0, 4,-1,  2, 2,-2},
166 165

  
167 166
        // algorithm1 rotated around the corner
168
        {1, 1, 1,  0, 2,-1,  2, 0,-1,  0, 2, 1,  2, 0, 1,
169
         0, 2,-1,  2, 0,-1,  0, 2, 1,  2, 0, 1,  1, 1,-1,
170
         2, 0,-1,  0, 2,-1,  2, 0, 1,  0, 2, 1,  2, 0,-1,
171
         0, 2,-1,  2, 0, 1,  0, 2, 1,  2, 1,-1,  2, 0,-1,
172
         0, 2,-2,  1, 0, 1,  0, 2, 2,  1, 0,-1,  0, 2,-2,
173
         2, 0, 1,  1, 1, 1,  2, 0,-1,  0, 2,-2,  1, 0, 1,
174
         0, 2, 2,  1, 0,-1,  0, 2,-2,  2, 0, 1,  1, 1,-2},
167
        {1, 2, 1,  0, 4,-1,  2, 1,-1,  0, 4, 1,  2, 1, 1,
168
         0, 4,-1,  2, 1,-1,  0, 4, 1,  2, 1, 1,  1, 2,-1,
169
         2, 1,-1,  0, 4,-1,  2, 1, 1,  0, 4, 1,  2, 1,-1,
170
         0, 4,-1,  2, 1, 1,  0, 4, 1,  2, 2,-1,  2, 1,-1,
171
         0, 4,-2,  1, 1, 1,  0, 4, 2,  1, 1,-1,  0, 4,-2,
172
         2, 1, 1,  1, 2, 1,  2, 1,-1,  0, 4,-2,  1, 1, 1,
173
         0, 4, 2,  1, 1,-1,  0, 4,-2,  2, 1, 1,  1, 2,-2},
175 174

  
176 175
        // algorithm1 rotated again around the corner
177
        {0, 2,-1,  2, 0, 1,  1, 0,-1,  2, 0,-1,  1, 0, 1,
178
         2, 0, 1,  1, 0,-1,  2, 0,-1,  1, 0, 1,  0, 2, 1,
179
         1, 0,-1,  2, 0, 1,  1, 0, 1,  2, 0,-1,  1, 0,-1,
180
         2, 0, 1,  1, 0, 1,  2, 0,-1,  1, 1,-1,  1, 0,-1,
181
         2, 0, 2,  0, 2,-1,  2, 0,-2,  0, 2, 1,  2, 0, 2,
182
         1, 0, 1,  0, 2,-1,  1, 0,-1,  2, 0, 2,  0, 2,-1,
183
         2, 0,-2,  0, 2, 1,  2, 0, 2,  1, 0, 1,  0, 2, 2},
176
        {0, 4,-1,  2, 1, 1,  1, 1,-1,  2, 1,-1,  1, 1, 1,
177
         2, 1, 1,  1, 1,-1,  2, 1,-1,  1, 1, 1,  0, 4, 1,
178
         1, 1,-1,  2, 1, 1,  1, 1, 1,  2, 1,-1,  1, 1,-1,
179
         2, 1, 1,  1, 1, 1,  2, 1,-1,  1, 2,-1,  1, 1,-1,
180
         2, 1, 2,  0, 4,-1,  2, 1,-2,  0, 4, 1,  2, 1, 2,
181
         1, 1, 1,  0, 4,-1,  1, 1,-1,  2, 1, 2,  0, 4,-1,
182
         2, 1,-2,  0, 4, 1,  2, 1, 2,  1, 1, 1,  0, 4, 2},
184 183

  
185 184
       // VTS' algorithm2: swap two 221 edges
186
        {2, 2, 1,  1, 0, 1,  2, 2,-1,  1, 0,-1,  1, 2, 1,
187
         2, 2,-2,  0, 2,-1,  2, 2, 2,  0, 2, 1,  2, 2,-2,
188
         1, 2,-1,  0, 2,-1,  1, 2, 1,  2, 2,-2,  0, 2,-1,
189
         2, 2, 2,  0, 2, 1,  2, 2,-2,  1, 2,-1,  0, 2,-2,
190
         1, 0, 1,  2, 2, 1,  1, 0,-1,  2, 2, -1},
185
        {2, 4, 1,  1, 1, 1,  2, 4,-1,  1, 1,-1,  1, 4, 1,
186
         2, 4,-2,  0, 4,-1,  2, 4, 2,  0, 4, 1,  2, 4,-2,
187
         1, 4,-1,  0, 4,-1,  1, 4, 1,  2, 4,-2,  0, 4,-1,
188
         2, 4, 2,  0, 4, 1,  2, 4,-2,  1, 4,-1,  0, 4,-2,
189
         1, 1, 1,  2, 4, 1,  1, 1,-1,  2, 4,-1},
191 190

  
192 191
       // algorithm2 rotated around the corner
193
        {0, 0,-1,  2, 0, 1,  0, 0, 1,  2, 0,-1,  2, 2, 1,
194
         0, 0, 2,  1, 0, 1,  0, 0,-2,  1, 0,-1,  0, 0, 2,
195
         2, 2,-1,  1, 1, 1,  2, 2, 1,  0, 0, 2,  1, 0, 1,
196
         0, 0,-2,  1, 0,-1,  0, 0, 2,  2, 2,-1,  1, 1, 2,
197
         2, 0, 1,  0, 0,-1,  2, 0,-1,  0, 0, 1},
192
        {0, 1,-1,  2, 1, 1,  0, 1, 1,  2, 1,-1,  2, 4, 1,
193
         0, 1, 2,  1, 1, 1,  0, 1,-2,  1, 1,-1,  0, 1, 2,
194
         2, 4,-1,  1, 2, 1,  2, 4, 1,  0, 1, 2,  1, 1, 1,
195
         0, 1,-2,  1, 1,-1,  0, 1, 2,  2, 4,-1,  1, 2, 2,
196
         2, 1, 1,  0, 1,-1,  2, 1,-1,  0, 1, 1},
198 197

  
199 198
       // algorithm2 rotated again around the corner
200
        {1, 2, 1,  0, 2,-1,  1, 2,-1,  0, 2, 1,  0, 0,-1,
201
         1, 2,-2,  2, 0, 1,  1, 2, 2,  2, 0,-1,  1, 2,-2,
202
         0, 0, 1,  2, 1, 1,  0, 0,-1,  1, 2,-2,  2, 0, 1,
203
         1, 2, 2,  2, 0,-1,  1, 2,-2,  0, 0, 1,  2, 1, 2,
204
         0, 2,-1,  1, 2, 1,  0, 2, 1,  1, 2,-1},
199
        {1, 4, 1,  0, 4,-1,  1, 4,-1,  0, 4, 1,  0, 1,-1,
200
         1, 4,-2,  2, 1, 1,  1, 4, 2,  2, 1,-1,  1, 4,-2,
201
         0, 1, 1,  2, 2, 1,  0, 1,-1,  1, 4,-2,  2, 1, 1,
202
         1, 4, 2,  2, 1,-1,  1, 4,-2,  0, 1, 1,  2, 2, 2,
203
         0, 4,-1,  1, 4, 1,  0, 4, 1,  1, 4,-1},
205 204

  
206 205
       // VTS' algorithm3: swap two 221 blocks
207
        {2, 2,-2,  0, 2,-1,  2, 2, 2,  0, 2, 1,  2, 2,-2,
208
         1, 2,-1,  0, 2,-1,  1, 2, 1,  2, 2,-2,  0, 2,-1,
209
         2, 2, 2,  0, 2, 1,  2, 2,-2,  1, 2,-1,  0, 2, 2,
210
         1, 2, 1 },
206
        {2, 4,-2,  0, 4,-1,  2, 4, 2,  0, 4, 1,  2, 4,-2,
207
         1, 4,-1,  0, 4,-1,  1, 4, 1,  2, 4,-2,  0, 4,-1,
208
         2, 4, 2,  0, 4, 1,  2, 4,-2,  1, 4,-1,  0, 4, 2,
209
         1, 4, 1 },
211 210

  
212 211
       // algorithm3 rotated around the corner
213
        {0, 0,-2,  1, 0, 1,  0, 0,-2,  1, 0,-1,  0, 0, 2,
214
         2, 2,-1,  1, 1, 1,  2, 2, 1,  0, 0, 2,  1, 0, 1,
215
         0, 0,-2,  1, 0,-1,  0, 0, 2,  2, 2,-1,  1, 1,-2,
216
         2, 2, 1 },
212
        {0, 1,-2,  1, 1, 1,  0, 1,-2,  1, 1,-1,  0, 1, 2,
213
         2, 4,-1,  1, 2, 1,  2, 4, 1,  0, 1, 2,  1, 1, 1,
214
         0, 1,-2,  1, 1,-1,  0, 1, 2,  2, 4,-1,  1, 4,-2,
215
         2, 4, 1 },
217 216

  
218 217
       // algorithm3 rotated again around the corner
219
        {1, 2, 2,  2, 0, 1,  1, 2, 2,  2, 0,-1,  1, 2,-2,
220
         0, 0, 1,  2, 1, 1,  0, 0,-1,  1, 2,-2,  2, 0, 1,
221
         1, 2, 2,  2, 0,-1,  1, 2,-2,  0, 0, 1,  2, 1,-2,
222
         0, 0,-1 }
218
        {1, 4, 2,  2, 1, 1,  1, 4, 2,  2, 1,-1,  1, 4,-2,
219
         0, 1, 1,  2, 2, 1,  0, 1,-1,  1, 4,-2,  2, 1, 1,
220
         1, 4, 2,  2, 1,-1,  1, 4,-2,  0, 1, 1,  2, 2,-2,
221
         0, 1,-1 }
223 222
      };
224 223
    }
225 224

  
src/main/java/org/distorted/objectlib/scrambling/ObjectScrambler.java
147 147

  
148 148
    int[] algorithm = mAlgorithms[mCurrAlgorithm];
149 149
    scramble[curr][0] = algorithm[mCurrStep  ];
150
    scramble[curr][1] = (1<<algorithm[mCurrStep+1]);
150
    scramble[curr][1] = algorithm[mCurrStep+1];
151 151
    scramble[curr][2] = algorithm[mCurrStep+2];
152 152

  
153 153
    mAxisExcluded = algorithm[0];
src/main/java/org/distorted/objectlib/scrambling/ScrambleEdgeGenerator.java
132 132
    int[][] ret = new int[num][3];
133 133
    int index = 0;
134 134

  
135
    for(int i=0; i<numAxis; i++)
135
    for(int a=0; a<numAxis; a++)
136 136
      {
137
      int numLayers = basicAngles[i].length;
137
      int numLayers = basicAngles[a].length;
138 138

  
139
      for(int j=0; j<numLayers; j++)
139
      for(int l=0; l<numLayers; l++)
140 140
        {
141
        int N = basicAngles[i][j];
141
        int N = basicAngles[a][l];
142 142
        int NEG = (1-N)/2;
143 143
        int POS = N/2;
144
        int layerBmp = (1<<l);
144 145

  
145 146
        for(int k=NEG; k<=-1; k++)
146 147
          {
147
          ret[index][0] = i;
148
          ret[index][1] = j;
148
          ret[index][0] = a;
149
          ret[index][1] = layerBmp;
149 150
          ret[index][2] = k;
150 151
          index++;
151 152
          }
152 153

  
153 154
        for(int k=1; k<=POS; k++)
154 155
          {
155
          ret[index][0] = i;
156
          ret[index][1] = j;
156
          ret[index][0] = a;
157
          ret[index][1] = layerBmp;
157 158
          ret[index][2] = k;
158 159
          index++;
159 160
          }
......
194 195
          int N = basicAngles[a][l];
195 196
          int NEG = (1-N)/2;
196 197
          int POS = N/2;
198
          int layerBmp = (1<<l);
197 199

  
198 200
          for(int k=NEG; k<=-1; k++)
199 201
            {
200 202
            ret[index][0] = a;
201
            ret[index][1] = l;
203
            ret[index][1] = layerBmp;
202 204
            ret[index][2] = k;
203 205
            index++;
204 206
            }
......
206 208
          for(int k=1; k<=POS; k++)
207 209
            {
208 210
            ret[index][0] = a;
209
            ret[index][1] = l;
211
            ret[index][1] = layerBmp;
210 212
            ret[index][2] = k;
211 213
            index++;
212 214
            }
src/main/java/org/distorted/objectlib/scrambling/ScrambleState.java
39 39
    mMoreThanOneAxis = moreThanOne;
40 40
    }
41 41

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

  
44
  private int getScrambleValue(int[] alg, int[][] scrambleTable)
45
    {
46
    int l=0, layerBmp = alg[1];
47

  
48
    for(; l<32; l++)
49
      {
50
      if( (layerBmp&0x1) !=0 ) break;
51
      layerBmp /= 2;
52
      }
53

  
54
    return scrambleTable[alg[0]][l];
55
    }
56

  
42 57
///////////////////////////////////////////////////////////////////////////////////////////////////
43 58

  
44 59
  public void getRandom(Random rnd, int[][] algorithms, int axisExcluded, int[][] scrambleTable, int[] numOccurences, int[] result)
......
53 68

  
54 69
      if( alg[0]!=axisExcluded )
55 70
        {
56
        int value = scrambleTable[alg[0]][alg[1]];
71
        int value = getScrambleValue(alg,scrambleTable);
57 72
        if( value>max ) max=value;
58 73
        }
59 74
      }
......
62 77
      {
63 78
      int[] alg = algorithms[mEdges[2*i]];
64 79
      int previous = (total==0 ? 0 : numOccurences[total-1]);
65
      if( alg[0]!=axisExcluded ) numOccurences[total] = 1+max-scrambleTable[alg[0]][alg[1]]+previous;
80
      if( alg[0]!=axisExcluded ) numOccurences[total] = 1+max+previous-getScrambleValue(alg,scrambleTable);
66 81
      else                       numOccurences[total] = previous;
67 82
      total++;
68 83
      }

Also available in: Unified diff