Example #1
0
        static void Main(string[] args)
        {
            /*Field field = new Field
             * (
             *  new int[,]
             *  {
             *      { 8, 0, 6},
             *      { 5, 4, 7},
             *      { 2, 3, 1}
             *
             *  }
             * );*/
            Field field = new Field
                          (
                new int[, ]
            {
                { 1, 2, 4, 7 },
                { 5, 12, 3, 8 },
                { 14, 0, 6, 10 },
                { 9, 13, 11, 15 }
            }
                          );

            BFSSolver    solver       = new BFSSolver(field);
            List <Field> fieldsPassed = solver.Search();

            foreach (var fieldPassed in fieldsPassed)
            {
                fieldPassed.PrintTiles();
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            //args = InitArgs();

            string path = "";// @"..\..\..\DataHandler\Data\";

            if (args.Length < 5)
            {
                Console.WriteLine("Too few arguments");
            }
            else
            {
                PuzzleSolver solver;
                switch (args[0])
                {
                case "bfs":
                {
                    solver = new BFSSolver(args[1], path + args[2], path + args[3], path + args[4]);
                    break;
                }

                case "dfs":
                {
                    solver = new DFSSolver(args[1], path + args[2], path + args[3], path + args[4]);
                    break;
                }

                case "iddfs":
                {
                    solver = new IterativeDeepeningDFSSolver(args[1], path + args[2], path + args[3], path + args[4]);
                    break;
                }

                case "astr":
                {
                    if (args[1] == "hamm")
                    {
                        solver = new HammingSolver(path + args[2], path + args[3], path + args[4]);
                    }
                    else if (args[1] == "manh")
                    {
                        solver = new ManhattanSolver(path + args[2], path + args[3], path + args[4]);
                    }
                    else
                    {
                        solver = new IterativeDeepeningAStar(path + args[2], path + args[3], path + args[4]);
                    }
                    break;
                }

                default:
                {
                    solver = new BFSSolver(args[1], path + args[2], path + args[3], path + args[4]);
                    break;
                }
                }
                solver.Solve();
            }
        }
Example #3
0
        public IActionResult SolvePuzzle(InputData input)
        {
            int[,] matrix = input.GetTilesMatrix();
            Field        field        = new Field(matrix);
            BFSSolver    solver       = new BFSSolver(field);
            List <Field> fields       = solver.Search();
            List <int[]> outputArrays = fields
                                        .Select(a => a.FlattenTiles())
                                        .ToList();
            OutputData outputData = new OutputData(outputArrays);

            return(Ok(outputData));
        }