Esempio n. 1
0
 public IEnumerable<ExecutionResult> Solve(ExecutionRequest request)
 {
     var moves = new List<MoveDirection>();
     ExecutionResult best = null;
     for (int i = 0; i < MaxIterations; i++) // while (true)
     {
         best = new SearchSolver().Solve(request).First();
         moves.AddRange(best.Commands);
         // select best move and move from it
         if (best.Snapshot.Finished)
         {
             break;
         };
         request = new ExecutionRequest
         {
             Snapshot = best.Snapshot,
             Options = request.Options
         };
         request.Options.MinEstimation = double.MinValue;
     }
     return new[]
     {
         new ExecutionResult
         {
             Snapshot = best.Snapshot,
             Commands = moves.ToArray(),
             Estimate = best.Estimate
         }
     };
 }
Esempio n. 2
0
        public MainWindow()
        {
            InitializeComponent();

            _input = JsonConvert.DeserializeObject<Input>(File.ReadAllText("input.json"));

            var options = JsonConvert.DeserializeObject<ExecutionOptions>(File.ReadAllText("options.json"));
            //new ExecutionOptions
            //{
            //	MaxWidth = 4,
            //	MaxHeight = 6,
            //	MinEstimation = double.MinValue,
            //	AttractorRatio = 10,
            //	DepthPenaltyRatio = 10,
            //	//HiddenHolesPenalty = 10,
            //	AdjacencyDownRatio = 5
            //}
            _execution = new ExecutionRequest
            {
                Snapshot = new Snapshot(_input, _input.SourceSeeds.First()),
                Options = options
            };

            _solver = new IterativeSearchSolver(4000); //new TraverseSolver();

            SizeChanged += (s, e) => Update();

            commandBar.SpawnEvent += commandBarSpawnEvent;
            commandBar.Move += commandBarMove;
            commandBar.StartSolver += commandBarStartSolver;
        }
Esempio n. 3
0
 public IEnumerable<ExecutionResult> Solve(ExecutionRequest request)
 {
     return Calculate(
         request.Snapshot,
         null,
         request.Options,
         (int)Math.Ceiling(request.Options.MaxHeight),
         request.Options.MinEstimation);
 }
Esempio n. 4
0
 private static ExecutionResult Calculate(Snapshot snapshot, ExecutionOptions options)
 {
     var request = new ExecutionRequest
     {
         Snapshot = snapshot,
         Options = options
     };
     var solver = new IterativeSearchSolver(1200); //new TraverseSolver();
     return solver.Solve(request).First();
 }