public IActionResult SolveStart(string id, bool stopOnSolution, double duration = 1) { var ident = PuzzleIdent.Parse(id); var p = compLib.GetPuzzleWithCaching(ident); var solver = new MultiThreadedForwardReverseSolver(new SolverNodeFactoryPoolingConcurrentBag("byteseq")); var solverCommand = new SolverCommand() { Puzzle = p.Puzzle, ExitConditions = new ExitConditions() { Duration = TimeSpan.FromMinutes(duration), StopOnSolution = true } }; var model = new SolverModel() { Token = DateTime.Now.Ticks, Puzzle = p, Command = solverCommand, State = solver.Init(solverCommand) }; staticState[model.Token] = model; model.Task = Task.Run(() => { solver.Solve(model.State); model.IsFinished = true; }); return(RedirectToAction("SolveMem", new { id, token = model.Token })); }
public SolverViewModel(SolverModel solverModel, InputModel inputModel, DrawingModel drawingModel) { _solverModel = solverModel; _inputModel = inputModel; _drawingModel = drawingModel; InitializeCommand(); }
private static SolverNode GetNode(SolverModel state, int?nodeid) { var node = nodeid == null ? state.RootForward : nodeid > 0 ? (state.RootForward?.Recurse().FirstOrDefault(x => x.SolverNodeId == nodeid.Value) ?? state.RootReverse?.Recurse().FirstOrDefault(x => x.SolverNodeId == nodeid.Value)) : state.RootReverse; return(node); }
public IActionResult StartFromFile(string file) { var fileName = Path.GetFileName(file); var ident = PuzzleIdent.Parse(fileName.Substring(0, fileName.IndexOf("-"))); var p = compLib.GetPuzzleWithCaching(ident); var solver = new MultiThreadedForwardReverseSolver(new SolverNodeFactoryPoolingConcurrentBag("byteseq")); var solverCommand = new SolverCommand() { Puzzle = p.Puzzle, ExitConditions = new ExitConditions() { Duration = TimeSpan.FromMinutes(0), StopOnSolution = true } }; var model = new SolverModel() { Token = DateTime.Now.Ticks, Puzzle = p, Command = solverCommand, }; staticState[model.Token] = model; model.Task = Task.Run(() => { var ser = new BinaryNodeSerializer(); using (var f = System.IO.File.OpenRead(file)) { using (var br = new BinaryReader(f)) { model.RootForward = ser.AssembleTree(br); } } model.IsFinished = true; }); return(RedirectToAction("SolveMem", new { id = ident.ToString(), token = model.Token })); }
public void SetSolverModel(SolverModel pModel) { Newton.NewtonSetSolverModel(m_Handle, (int)pModel); }
//NOTE: Use Adaptive for games (exact is slow) public void SetSolverModel(SolverModel model) { Newton.NewtonSetSolverModel(_handle, (int)model); }
public void SetSolverModel(SolverModel model) { NativeAPI.SetSolverModel(handle, (int)model); }