public void CancellingTurns_RemovedFromSequence(string orig, string final) { var move = TurnSequence.Parse(orig); string s = move.ToString(); Assert.Equal(final, s); }
static TurnSequenceMove[] CalculatedAllowedMovesForSlot(FtlSlot slot) { Turn u0 = new Turn(Side.Up, Rotation.Clockwise); Turn u1 = new Turn(Side.Up, Rotation.CounterClockwise); Turn u2 = new Turn(Side.Up, Rotation.Twice); Turn leftOfSlotUp = new Turn(slot.LeftOf, Rotation.CounterClockwise); Turn leftOfSlotDown = new Turn(slot.LeftOf, Rotation.Clockwise); Turn rightOfSlotUp = new Turn(slot.RightOf, Rotation.Clockwise); Turn rightOfSlotDown = new Turn(slot.RightOf, Rotation.CounterClockwise); var allowedMoves = new TurnSequence[] { new TurnSequence(u0), new TurnSequence(u1), new TurnSequence(u2), new TurnSequence(rightOfSlotUp, u0, rightOfSlotDown), new TurnSequence(rightOfSlotUp, u1, rightOfSlotDown), new TurnSequence(rightOfSlotUp, u2, rightOfSlotDown), new TurnSequence(leftOfSlotUp, u0, leftOfSlotDown), new TurnSequence(leftOfSlotUp, u1, leftOfSlotDown), new TurnSequence(leftOfSlotUp, u2, leftOfSlotDown), }.Select(x => new TurnSequenceMove(x)) .ToArray(); return(allowedMoves); }
public void ParseSeriesRoundTrip(string expected) { var turns = TurnSequence.Parse(expected); string actual = turns.ToString(); Assert.Equal(expected, actual); }
static TurnSequenceMove[] CalculateMovesForPoppingCubeIntoTopRow(FtlSlot slot) { // !!! if there is already a cube in the top, // we might want to include the top turns, so cube currently in top, doesn't go into bottom. // !!! option: instead of adding this on, to SlotTurnGenerator, // just have extra step in solver to pop cube up, // then filter out any first moves that don't have both cubes in top // !!! also, when picking best move, perhaps secondary criteria is // to not put any other slot cubes in the slot we just vacated. Turn u0 = new Turn(Side.Up, Rotation.Clockwise); Turn u1 = new Turn(Side.Up, Rotation.CounterClockwise); Turn u2 = new Turn(Side.Up, Rotation.Twice); Turn leftOfSlotUp = new Turn(slot.LeftOf, Rotation.CounterClockwise); Turn leftOfSlotDown = new Turn(slot.LeftOf, Rotation.Clockwise); Turn rightOfSlotUp = new Turn(slot.RightOf, Rotation.Clockwise); Turn rightOfSlotDown = new Turn(slot.RightOf, Rotation.CounterClockwise); var allowedMoves = new TurnSequence[] { new TurnSequence(u0), new TurnSequence(u1), new TurnSequence(u2), new TurnSequence(rightOfSlotUp, u0, rightOfSlotDown), new TurnSequence(rightOfSlotUp, u1, rightOfSlotDown), new TurnSequence(rightOfSlotUp, u2, rightOfSlotDown), new TurnSequence(leftOfSlotUp, u0, leftOfSlotDown), new TurnSequence(leftOfSlotUp, u1, leftOfSlotDown), new TurnSequence(leftOfSlotUp, u2, leftOfSlotDown), }.Select(x => new TurnSequenceMove(x)) .ToArray(); return(allowedMoves); }
static TurnSequence GetCrossSolution_Inner(Cube cube, int i) { Edge[] e = Enumerable.Range(0, 4) .Select(x => Constraints.CrossEdges[(i + x) % 4]) .ToArray(); TurnSequence move1Turns = Solve_First2CrossEdges(cube, e[0], e[1]); TurnSequence move2Turns = Solve_Second2CrossEdges(cube.Apply(move1Turns), e[0], e[1], e[2], e[3]); return(new TurnSequence(move1Turns._turns.Concat(move2Turns._turns).ToArray())); }
public void CanSolveCross(string mixItUpMove) { var mixItUpTurns = TurnSequence.Parse(mixItUpMove); var cube = new Cube().Apply(mixItUpTurns); // When: get cross solution and apply it var solution = Solver.GetCrossSolution(cube); cube = cube.Apply(solution); // Then: cross is solved Assert.True(EdgeConstraint.Stationary(new Edge(Side.Front, Side.Down)).IsMatch(cube)); Assert.True(EdgeConstraint.Stationary(new Edge(Side.Right, Side.Down)).IsMatch(cube)); Assert.True(EdgeConstraint.Stationary(new Edge(Side.Back, Side.Down)).IsMatch(cube)); Assert.True(EdgeConstraint.Stationary(new Edge(Side.Left, Side.Down)).IsMatch(cube)); }
[InlineData("RU'R'UF'U2FUF'U2F")] // RU'R'dR'U2RUR'U2R public void F2L(string knownSolution) { var solveTurns = TurnSequence.Parse(knownSolution); var cube = new Cube().Apply(solveTurns.Reverse()); Assert.True(cube.Apply(solveTurns).IsSolved, "not solved"); var pair = new FtlSlot(Side.Front, Side.Right); var prepSolution = Solver.PlaceSingleFtlPairFromTop(pair, cube); cube = cube.Apply(prepSolution); Assert_F2LSolved(cube); Assert_CrossSolved(cube); }
public TurnSequenceMove(TurnSequence turns) => _sequence = turns;