Exemple #1
0
        public void AddToHistoryIfNotDuplicate(Cube state)
        {
            Cube oldOne = FindExactMatch(state);

            if (oldOne != null)
            {
                state.Print();

                using (new ConsoleColor((int)ConsoleColor.ForeGroundColor.Yellow | 0x8))
                {
                    Console.WriteLine($"The above is duplicate state to step = {oldOne.Step}, path = {oldOne.Path} ignored");
                }
            }
            else
            {
                oldOne = FindSimilarMatch(state);

                if (oldOne != null)
                {
                    using (new ConsoleColor((int)ConsoleColor.ForeGroundColor.Yellow))
                    {
                        Console.WriteLine($"Warning: the above is simliar state to step = {oldOne.Step}, path = {oldOne.Path}");
                    }
                }
                Add(state);

                PrintLastState();
            }
        }
Exemple #2
0
        public static Cube ApplyActions(Cube side, string[] actions)
        {
            side.Print();

            foreach (var action in actions)
            {
                if (!String.IsNullOrEmpty(action))
                {
                    allMoves[action].Action(side);

                    side.Step++;
                    side.Path += action;

                    side.Print();
                }
            }
            return(side);
        }