Beispiel #1
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);
                }
            }
        }