/// <summary>
 /// Creates a new service provider.
 /// </summary>
 /// <param name="handler">A callback object used when the the user needs to be asked questions or informed about download and IO tasks.</param>
 public ServiceProvider(ITaskHandler handler)
 {
     Handler                     = handler ?? throw new ArgumentNullException(nameof(handler));
     _feedCache                  = new(() => FeedCaches.Default(OpenPgp));
     _trustManager               = new(() => new(TrustDB.LoadSafe(), Config, OpenPgp, FeedCache, Handler));
     _feedManager                = new(() => new(Config, FeedCache, TrustManager, Handler));
     _catalogManager             = new(() => new(TrustManager, Handler));
     _selectionCandidateProvider = new(() => new(Config, FeedManager, ImplementationStore, PackageManager));
     _solver                     = new(() =>
     {
         var backtrackingSolver = new BacktrackingSolver(SelectionCandidateProvider);
         if (Config.ExternalSolverUri == null)
         {
             return(backtrackingSolver);
         }
         else
         {
             var externalSolver = new ExternalSolver(backtrackingSolver, SelectionsManager, Fetcher, Executor, FeedManager, Handler, Config.ExternalSolverUri);
             return(new FallbackSolver(backtrackingSolver, externalSolver));
         }
     });
     _fetcher           = new(() => new(Config, ImplementationStore, Handler));
     _executor          = new(() => new(ImplementationStore));
     _selectionsManager = new(() => new(FeedManager, ImplementationStore, PackageManager));
 }
Beispiel #2
0
        /// <summary>
        /// Attempts to Solve game board using provided algorithm
        /// </summary>
        /// <returns></returns>
        public bool Solve(out string solutionWord, out string pathWord)
        {
            BacktrackingSolver solver = new BacktrackingSolver(boardDefinition);

            if (PlayerPositionChanged != null)
            {
                solver.PlayerPositionChanged += Solver_PlayerPositionChanged;
            }

            Point startPos = boardDefinition.PlayerStartPosition;

            var solution = solver.FindSolution(
                startPos.X,
                startPos.Y,
                boardDefinition.BoardWordSolution,
                boardDefinition.BoardSolution);


            bool solutionFound = solution.SolutionFound;

            solutionWord = solution.SolutionWord;
            pathWord     = solution.PathWord;

            return(solutionFound);
        }