Exemplo n.º 1
0
        private static void SolveSingleProblem(string problemPath)
        {
            String problemExtension     = ".desc";
            String problemTempSolutions = ".tmp";
            String problemSolution      = ".sol";

            if (File.Exists(problemPath + problemExtension))
            {
                string problem = File.ReadAllText(problemPath + problemExtension);
                List <List <Action> > tempSolutions = new List <List <Action> >();
                if (File.Exists(problemPath + problemTempSolutions))
                {
                    tempSolutions = ParseTempSolution(problemPath, problemTempSolutions);
                }

                Status status = Parser.parseProblem(problem);
                if (!"".Equals(StupidPrinterOutputPath))
                {
                    StupidPrettyPrinter.PrintParsedMap(status, StupidPrinterOutputPath);
                }

                Solver solver = new Solver(status, tempSolutions);
                solver.Loop();
                PrintSolution(problemPath, problemSolution, status);
            }
        }
Exemplo n.º 2
0
        public Solver(Status status0, List <List <Action> > wrappiesStartingActions)
        {
            this.status = status0;
            this.wrappiesStartingActions = wrappiesStartingActions;

            for (int i = 0; i < this.wrappiesStartingActions.Count; i++)
            {
                var wacs = this.wrappiesStartingActions[i];
                foreach (var wac in wacs)
                {
                    if (status.wrappies.Count <= i)
                    {
                        throw new Exception("Malformed starting action: Using a not spawned wrappy");
                    }
                    status.execute(wac, status.wrappies[i]);
                    StupidPrettyPrinter.PrintCurrentSemiFilledMap(status);
                }
            }
            StatisticalPrettyPrinter.printStats(status);
        }