Example #1
0
 private static IState GetState(IState parentState, XElement stateElement, Solver solver)
 => stateElement == null
         ? parentState
         : StateParser.Parse(null, parentState, stateElement, solver).State;
Example #2
0
 private static Solver SolverWithPuzzleStates(this Solver initialSolver, XDocument document)
 => (from statesElement in document.Root.Elements("States")
Example #3
0
        private static (Algorithm Algorithm, PuzzleColor[] Colors) GetBaseAlgorithm(XElement element, Solver solver)
        {
            var attribute = element.Attribute("Base");

            if (attribute == null)
            {
                return(Algorithm.Empty, null);
            }

            var(name, colors) = ExpressionParser.ParseInner(attribute.Value);
            Algorithm algorithm;

            if (!solver.AlgorithmTemplates.TryGetValue(name, out algorithm))
            {
                if (!solver.Algorithms.TryGetValue(name, out algorithm))
                {
                    throw new InvalidOperationException($"The '{name}' algorithm or algorithm template could not be found.");
                }
            }

            return(algorithm, colors);
        }