Пример #1
0
        private void IteratePhase2(ISolveCoordinator solveCoordinator)
        {
            var togo2Limit = Math.Min(solveCoordinator.MaxTotalMoves - MovesSoFar.Count, 11);

            if (Cube.CornsliceDepth !.Value >= togo2Limit)
            {
                return; // this check speeds up the computation
            }
            uint nextDepth;

            if (Cube.CornersUdEdgesDepthMod3 !.Value == 0)
            {
                nextDepth = 2;
            }
Пример #2
0
        private void IteratePhase1(ISolveCoordinator solveCoordinator)
        {
            uint nextDepth;

            if (Cube.FlipsliceTwistDepthMod3 == 0)
            {
                nextDepth = 2;
            }
            else
            {
                nextDepth = Cube.FlipsliceTwistDepthMod3 - 1;
            }

            if (nextDepth + 1 + MovesDeep >= solveCoordinator.MaxTotalMoves)
            {
                return;//No way to solve in time
            }
            ImmutableArray <Move> moves;

            if (MovesSoFar.Any())
            {
                moves = MoveExtensions.PossibleNextMovesPhase1[(int)MovesSoFar.Head];
            }
            else
            {
                moves = MoveExtensions.AllMoves;
            }

            foreach (var moveEnum in moves)
            {
                var nextCube = Cube.Move(moveEnum, solveCoordinator.DataSource);

                var nextIsDeepening = nextCube.FlipsliceTwistDepthMod3 == nextDepth;

                if (nextIsDeepening || (!Deepening && MovesDeep <= 2))  //Once we are deepening, we do not allow non-deepening moves
                {
                    var nextState = new SearchState(Invert, Rotation, nextCube, MovesSoFar.Prepend(moveEnum),
                                                    nextIsDeepening);

                    solveCoordinator.MaybeAddSearch(nextState);
                }
            }
        }
Пример #3
0
        public void Iterate(ISolveCoordinator solveCoordinator)
        {
            switch (Cube.CurrentPhase)
            {
            case Phase.Phase1:
                IteratePhase1(solveCoordinator);
                break;

            case Phase.Phase2:
                IteratePhase2(solveCoordinator);
                break;

            case Phase.Solved:
                solveCoordinator.TryAddSolution(Solution.Create(MovesSoFar, Invert, Rotation));
                break;

            default:
                throw new InvalidEnumArgumentException();
            }
        }