private int getLayerOrder(SwipedFace ignore) { List <SwipedFace> orderedFaces = swipedFaces; orderedFaces.Remove(ignore); for (int i = 1; i < orderedFaces.Count; i++) { if (orderedFaces[i].layer < orderedFaces[i - 1].layer) { return(-1); } } return(1); }
public KeyValuePair <Move, RotationDirection> getMove() { KeyValuePair <Move, RotationDirection> retval = new KeyValuePair <Move, RotationDirection>(Move.None, RotationDirection.None); if (swipedFaces.Count < 3) { return(retval); } CubeFace f = getDominantFace(); if (f == CubeFace.None) { return(retval); } filterMoves(f); SwipeDirection dir = getSingleDirection(); if (dir == SwipeDirection.None) { return(retval); } SwipedFace swipedFace = getSingleSwipedFace(dir); //Debug.Print("face: {0}{1}{2}", swipedFace.face, swipedFace.direction, swipedFace.layer); Move m = Move.None; switch (swipedFace.face) { case CubeFace.F: case CubeFace.B: switch (swipedFace.direction) { case SwipeDirection.H: switch (swipedFace.layer) { case 0: m = Move.U; break; case 1: m = Move.E; break; case 2: m = Move.D; break; } break; case SwipeDirection.V: switch (swipedFace.layer) { case 0: m = Move.L; break; case 1: m = Move.M; break; case 2: m = Move.R; break; } break; } break; case CubeFace.R: case CubeFace.L: switch (swipedFace.direction) { case SwipeDirection.H: switch (swipedFace.layer) { case 0: m = Move.D; break; case 1: m = Move.E; break; case 2: m = Move.U; break; } break; case SwipeDirection.V: switch (swipedFace.layer) { case 0: m = Move.B; break; case 1: m = Move.S; break; case 2: m = Move.F; break; } break; } break; case CubeFace.U: case CubeFace.D: switch (swipedFace.direction) { case SwipeDirection.H: switch (swipedFace.layer) { case 0: m = Move.B; break; case 1: m = Move.S; break; case 2: m = Move.F; break; } break; case SwipeDirection.V: switch (swipedFace.layer) { case 0: m = Move.L; break; case 1: m = Move.M; break; case 2: m = Move.R; break; } break; } break; } retval = new KeyValuePair <Move, RotationDirection>(m, getRotationDirection(swipedFace)); Debug.Print("Move: " + retval.ToString()); return(retval); }
private RotationDirection getRotationDirection(SwipedFace f) { Dictionary<CubeFace, Dictionary<SwipeDirection, Dictionary<int, RotationDirection>>> dirs = new Dictionary<CubeFace, Dictionary<SwipeDirection, Dictionary<int, RotationDirection>>> { {CubeFace.F, new Dictionary<SwipeDirection, Dictionary<int, RotationDirection>>{ {SwipeDirection.V, new Dictionary<int, RotationDirection>{ {0, RotationDirection.ClockWise}, {1, RotationDirection.ClockWise}, {2, RotationDirection.CounterClockWise} }}, {SwipeDirection.H, new Dictionary<int, RotationDirection>{ {0, RotationDirection.CounterClockWise}, {1, RotationDirection.ClockWise}, {2, RotationDirection.ClockWise} }} }}, {CubeFace.R, new Dictionary<SwipeDirection, Dictionary<int, RotationDirection>>{ {SwipeDirection.V, new Dictionary<int, RotationDirection>{ {0, RotationDirection.ClockWise}, {1, RotationDirection.CounterClockWise}, {2, RotationDirection.CounterClockWise} }}, {SwipeDirection.H, new Dictionary<int, RotationDirection>{ {0, RotationDirection.CounterClockWise}, {1, RotationDirection.CounterClockWise}, {2, RotationDirection.ClockWise} }} }}, {CubeFace.B, new Dictionary<SwipeDirection, Dictionary<int, RotationDirection>>{ {SwipeDirection.V, new Dictionary<int, RotationDirection>{ {0, RotationDirection.CounterClockWise}, {1, RotationDirection.CounterClockWise}, {2, RotationDirection.ClockWise} }}, {SwipeDirection.H, new Dictionary<int, RotationDirection>{ {0, RotationDirection.ClockWise}, {1, RotationDirection.CounterClockWise}, {2, RotationDirection.CounterClockWise} }} }}, {CubeFace.L, new Dictionary<SwipeDirection, Dictionary<int, RotationDirection>>{ {SwipeDirection.V, new Dictionary<int, RotationDirection>{ {0, RotationDirection.CounterClockWise}, {1, RotationDirection.ClockWise}, {2, RotationDirection.ClockWise} }}, {SwipeDirection.H, new Dictionary<int, RotationDirection>{ {0, RotationDirection.ClockWise}, {1, RotationDirection.ClockWise}, {2, RotationDirection.CounterClockWise} }} }}, {CubeFace.U, new Dictionary<SwipeDirection, Dictionary<int, RotationDirection>>{ {SwipeDirection.V, new Dictionary<int, RotationDirection>{ {0, RotationDirection.ClockWise}, {1, RotationDirection.ClockWise}, {2, RotationDirection.CounterClockWise} }}, {SwipeDirection.H, new Dictionary<int, RotationDirection>{ {0, RotationDirection.CounterClockWise}, {1, RotationDirection.ClockWise}, {2, RotationDirection.ClockWise} }} }}, {CubeFace.D, new Dictionary<SwipeDirection, Dictionary<int, RotationDirection>>{ {SwipeDirection.V, new Dictionary<int, RotationDirection>{ {0, RotationDirection.CounterClockWise}, {1, RotationDirection.CounterClockWise}, {2, RotationDirection.ClockWise} }}, {SwipeDirection.H, new Dictionary<int, RotationDirection>{ {0, RotationDirection.ClockWise}, {1, RotationDirection.CounterClockWise}, {2, RotationDirection.CounterClockWise} }} }}, }; return (RotationDirection)(Convert.ToInt32(dirs[f.face][f.direction][f.layer]) * getLayerOrder(f)); }
private RotationDirection getRotationDirection(SwipedFace f) { Dictionary <CubeFace, Dictionary <SwipeDirection, Dictionary <int, RotationDirection> > > dirs = new Dictionary <CubeFace, Dictionary <SwipeDirection, Dictionary <int, RotationDirection> > > { { CubeFace.F, new Dictionary <SwipeDirection, Dictionary <int, RotationDirection> > { { SwipeDirection.V, new Dictionary <int, RotationDirection> { { 0, RotationDirection.ClockWise }, { 1, RotationDirection.ClockWise }, { 2, RotationDirection.CounterClockWise } } }, { SwipeDirection.H, new Dictionary <int, RotationDirection> { { 0, RotationDirection.CounterClockWise }, { 1, RotationDirection.ClockWise }, { 2, RotationDirection.ClockWise } } } } }, { CubeFace.R, new Dictionary <SwipeDirection, Dictionary <int, RotationDirection> > { { SwipeDirection.V, new Dictionary <int, RotationDirection> { { 0, RotationDirection.ClockWise }, { 1, RotationDirection.CounterClockWise }, { 2, RotationDirection.CounterClockWise } } }, { SwipeDirection.H, new Dictionary <int, RotationDirection> { { 0, RotationDirection.CounterClockWise }, { 1, RotationDirection.CounterClockWise }, { 2, RotationDirection.ClockWise } } } } }, { CubeFace.B, new Dictionary <SwipeDirection, Dictionary <int, RotationDirection> > { { SwipeDirection.V, new Dictionary <int, RotationDirection> { { 0, RotationDirection.CounterClockWise }, { 1, RotationDirection.CounterClockWise }, { 2, RotationDirection.ClockWise } } }, { SwipeDirection.H, new Dictionary <int, RotationDirection> { { 0, RotationDirection.ClockWise }, { 1, RotationDirection.CounterClockWise }, { 2, RotationDirection.CounterClockWise } } } } }, { CubeFace.L, new Dictionary <SwipeDirection, Dictionary <int, RotationDirection> > { { SwipeDirection.V, new Dictionary <int, RotationDirection> { { 0, RotationDirection.CounterClockWise }, { 1, RotationDirection.ClockWise }, { 2, RotationDirection.ClockWise } } }, { SwipeDirection.H, new Dictionary <int, RotationDirection> { { 0, RotationDirection.ClockWise }, { 1, RotationDirection.ClockWise }, { 2, RotationDirection.CounterClockWise } } } } }, { CubeFace.U, new Dictionary <SwipeDirection, Dictionary <int, RotationDirection> > { { SwipeDirection.V, new Dictionary <int, RotationDirection> { { 0, RotationDirection.ClockWise }, { 1, RotationDirection.ClockWise }, { 2, RotationDirection.CounterClockWise } } }, { SwipeDirection.H, new Dictionary <int, RotationDirection> { { 0, RotationDirection.CounterClockWise }, { 1, RotationDirection.ClockWise }, { 2, RotationDirection.ClockWise } } } } }, { CubeFace.D, new Dictionary <SwipeDirection, Dictionary <int, RotationDirection> > { { SwipeDirection.V, new Dictionary <int, RotationDirection> { { 0, RotationDirection.CounterClockWise }, { 1, RotationDirection.CounterClockWise }, { 2, RotationDirection.ClockWise } } }, { SwipeDirection.H, new Dictionary <int, RotationDirection> { { 0, RotationDirection.ClockWise }, { 1, RotationDirection.CounterClockWise }, { 2, RotationDirection.CounterClockWise } } } } }, }; return((RotationDirection)(Convert.ToInt32(dirs[f.face][f.direction][f.layer]) * getLayerOrder(f))); }
private int getLayerOrder(SwipedFace ignore) { List<SwipedFace> orderedFaces = swipedFaces; orderedFaces.Remove(ignore); for (int i = 1; i < orderedFaces.Count; i++) { if (orderedFaces[i].layer < orderedFaces[i - 1].layer) { return -1; } } return 1; }