Project

General

Profile

« Previous | Next » 

Revision 99b18adc

Added by Leszek Koltunski 4 days ago

Phased Solver app: debugging

View differences:

src/main/java/org/distorted/phasedsolver/SolverActivity.java
207 207
      int[][] whiteCross   = new int[][]{ {12,13,16,17} };
208 208
      int[][] whiteCorners = new int[][]{ {0},{1},{2},{3} };
209 209
      int[][] secondLayer  = new int[][]{ {8},{9},{10},{11} };
210
      int yellowCrossCubit = 14;
211
      int yellowCrossQuat  = 1;
210

  
211
      int[][] yellowEdges  = new int[][]{ {14,15,18,19} };
212
      String lleoA = "(11,17,5,15,3,9)";
213
      String lleoB = "(17,6,5,8,3,15)";
214
      String lleoC = "(6,12,5,14,3,8)";
215
      String lleoD = "(12,11,5,9,3,14)";
216
      String llEdgesOrie = lleoA+"{0,1,2} "+lleoB+"{0,1,2} "+lleoC+"{0,1,2} "+lleoD+"{0,1,2}";
217
      String llepA = "(6,5,8,5,6,4,8)";
218
      String llepB = "(12,5,14,5,12,4,14)";
219
      String llepC = "(11,5,9,5,11,4,9)";
220
      String llEdgesPerm = "(3){0,1} ["+llepA+"{-1,0,1};"+llepB+"] "+llepC+"{-1,0,1}";
221
      String llEdges = lleoA+" "+lleoA+" "+lleoC+" (3) "+llepA+" "+llepC;//llEdgesOrie+" "+llEdgesPerm;
222

  
212 223
      int[][] yellowCorners= new int[][]{ {4,5,6,7} };
213
      String partA = "(5,6,3,9,5,8,3,11)";
214
      String partB = "(5,12,3,15,5,14,3,17)";
215
      String partC = "(5,11,3,8,5,9,3,6)";
216
      String regex1 = "["+partA+"{-1,0,1};"+partB+"] "+partC+"{-1,0,1}";
217
      String part = "(3,8,5,6){-2,0,2} (11)";
218
      String regex2 = part+" "+part+" "+part+" "+part;
219
      String regex = regex1+" "+regex2;
224
      String llcpA = "(5,6,3,9,5,8,3,11)";
225
      String llcpB = "(5,12,3,15,5,14,3,17)";
226
      String llcpC = "(5,11,3,8,5,9,3,6)";
227
      String llCornersPerm = "["+llcpA+"{-1,0,1};"+llcpB+"] "+llcpC+"{-1,0,1}";
228
      String llco  = "(3,8,5,6){-2,0,2} (11)";
229
      String llCornersOrie = llco+" "+llco+" "+llco+" "+llco;
230
      String llCorners = llCornersPerm+" "+llCornersOrie;
220 231

  
221 232
      Phase[] phases =
222 233
              {
223 234
                new PhaseNotCyclic( mObject, whiteCross),
224 235
                new PhaseNotCyclic( mObject, whiteCorners),
225 236
                new PhaseNotCyclic( mObject, secondLayer),
226
                new PhaseCyclicOrie1( mObject, yellowCrossCubit , yellowCrossQuat ),
227
                new PhaseCyclicPerm2( mObject, yellowCrossCubit , yellowCrossQuat ),
228
                new PhaseRegex( mObject, regex, yellowCorners ),
237
                new PhaseRegex( mObject, llEdges  , yellowEdges   ),
238
              //  new PhaseRegex( mObject, llCorners, yellowCorners ),
229 239
              };
230 240

  
231 241
      PhasedSolver ps = new PhasedSolver(mObject,phases);
src/main/java/org/distorted/phasedsolver/SolverLowerPane.java
13 13

  
14 14
import org.distorted.objectlib.helpers.MovesFinished;
15 15
import org.distorted.objectlib.main.ObjectControl;
16
import org.distorted.objectlib.main.TwistyObject;
16 17

  
17 18
///////////////////////////////////////////////////////////////////////////////////////////////////
18 19

  
......
52 53
      });
53 54
    }
54 55

  
56
///////////////////////////////////////////////////////////////////////////////////////////////////
57

  
58
  private int[][] transformMoves(int[][] moves, boolean back)
59
    {
60
    int len = moves.length;
61
    int[][] ret = new int[len][];
62
    int mult = back ? -1:1;
63

  
64
    for(int m=0; m<len; m++)
65
      {
66
      int[] mv = moves[back ? m : len-1-m];
67
      int[] rt = new int[3];
68

  
69
      rt[0] = mv[0];
70
      rt[1] = (1<<mv[1]);
71
      rt[2] = mult*mv[2];
72

  
73
      ret[m] = rt;
74
      }
75

  
76
    return ret;
77
    }
78

  
55 79
///////////////////////////////////////////////////////////////////////////////////////////////////
56 80

  
57 81
  void setMoves(SolverActivity act, int[][] moves)
......
74 98

  
75 99
  void backMove(SolverActivity act)
76 100
    {
77
    if( mMoves!=null && mCanMove && mCurrMove>0 )
101
    if( mMoves!=null && mCanMove )
78 102
      {
79
      mCanMove = false;
80
      int[] move = mMoves[--mCurrMove];
81
      setText(act);
103
      if( mCurrMove>0 )
104
        {
105
        mCanMove = false;
106
        int[] move = mMoves[--mCurrMove];
107
        mControl = act.getControl();
108
        mControl.blockTouch(MOVES_PLACE_0);
109
        mControl.addRotation(this, move[0], (1<<move[1]), move[2], MILLIS_PER_DEGREE);
110
        }
111
      else
112
        {
113
        mCurrMove = mNumMoves;
114
        mControl = act.getControl();
115
        int[][] moves = transformMoves(mMoves,true);
116
        mControl.applyScrambles(moves);
117
        }
82 118

  
83
      mControl = act.getControl();
84
      mControl.blockTouch(MOVES_PLACE_0);
85
      mControl.addRotation(this, move[0], (1<<move[1]), move[2], MILLIS_PER_DEGREE);
119
      setText(act);
86 120
      }
87 121
    }
88 122

  
......
90 124

  
91 125
  void makeMove(SolverActivity act)
92 126
    {
93
    if( mMoves!=null && mCanMove && mCurrMove<mNumMoves )
127
    if( mMoves!=null && mCanMove )
94 128
      {
95
      mCanMove = false;
96
      int[] move = mMoves[mCurrMove++];
97
      setText(act);
129
      if( mCurrMove<mNumMoves )
130
        {
131
        mCanMove = false;
132
        int[] move = mMoves[mCurrMove++];
133
        mControl = act.getControl();
134
        mControl.blockTouch(MOVES_PLACE_1);
135
        mControl.addRotation(this, move[0], (1<<move[1]), -move[2], MILLIS_PER_DEGREE);
136
        }
137
      else
138
        {
139
        mCurrMove = 0;
140
        mControl = act.getControl();
141
        int[][] moves = transformMoves(mMoves,false);
142
        mControl.applyScrambles(moves);
143
        }
98 144

  
99
      mControl = act.getControl();
100
      mControl.blockTouch(MOVES_PLACE_1);
101
      mControl.addRotation(this, move[0], (1<<move[1]), -move[2], MILLIS_PER_DEGREE);
145
      setText(act);
102 146
      }
103 147
    }
104 148

  

Also available in: Unified diff