public string SolveBoard(string path, int rows, int cols, int width, int height, int w_off, int h_off) { path = Uri.UnescapeDataString(path); Console.WriteLine(path); Bitmap bmp = new Bitmap(path); Board b = PadImage.BoardFromBitmap(rows, cols, height, width, h_off, w_off, bmp); return(JsonConvert.SerializeObject(DfsSolver.GetBestPath(b))); }
public string SolveBoard2(string path, int rows, int cols, int width, int height, int w_off, int h_off) { path = Uri.UnescapeDataString(path); Console.WriteLine(path); Bitmap bmp = new Bitmap(path); Board b = PadImage.BoardFromBitmap(rows, cols, height, width, h_off, w_off, bmp); return(JsonConvert.SerializeObject(BeamDfs.GetBestPath(b, BoardScorer.Options.Horus))); //return JsonConvert.SerializeObject(BeamDfs.GetBestPath(b, Teams.LuBu)); }
public IActionResult Upload(int id, IFormFile file) { var pad = this.pads.Get(id); if (pad == null) { return(NotFound(id.ToString())); } if (file.Length > 0) { var imagesPath = Path.Combine(this.hostingEnvironment.ContentRootPath, GlobalConstants.PathToPadImages.FixOsPath()); var path = imagesPath + id.ToString(); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } var name = Guid.NewGuid().ToString(); var type = file.ContentType.Split('/'); var filePath = Path.Combine(path, name + "." + type[1]); using (var stream = new FileStream(filePath, FileMode.Create)) { file.CopyTo(stream); } var image = new PadImage() { Pad = pad, Path = $"/pads/{id}/{name}.{type[1]}", }; pad.Images.Add(image); this.pads.Save(); } return(this.RedirectToAction("Edit", "Pad", new { area = "Admin", id = id })); }
public string TestSAAS(string path, int rows, int cols, int width, int height, int w_off, int h_off) { path = Uri.UnescapeDataString(path); Console.WriteLine(path); Bitmap bmp = new Bitmap(path); Board b = PadImage.BoardFromBitmap(rows, cols, height, width, h_off, w_off, bmp); Board opt = SAASSolver.GetOptimalBoards(b, SAASSolver.Options.Default, BoardScorer.Options.Horus).First(); var b3 = new Board(opt); b3.GetCombos(false); //var p2 = SAASSolver.GetBestPathSA(b, SAASSolver.Options.Default, BoardScorer.Options.Horus); //var b4 = b.GetBoardsAfterPath(p2.Start.Item1, p2.Start.Item2, p2.Actions); return("" + b.ToString() + "\n\nSAAS optimal:" + opt.ToString() + b3.ToString() + "\n\n" + opt.Score(BoardScorer.Options.Horus) + "\n\n"); // + JsonConvert.SerializeObject(p2) // + b4.Item1.ToString() // + b4.Item2.ToString(); }