public UserController(ILogger <UserController> logger, IAuthService authService, UserService userService, MazeService mazeService) { _logger = logger; _authService = authService; _userService = userService; _mazeService = mazeService; }
public void Setup() { _mazeService = new MazeService(); string dir = Path.GetDirectoryName(Path.GetDirectoryName(Directory.GetCurrentDirectory())); _filePath = Path.Combine(dir, "ExampleMaze.txt"); }
public ActionResult Generate() { Maze maze = MazeService.Generate(10, 20); DL.Maze mazeDb = MazeService.CreateMazeDb(maze); return(RedirectToAction("Display", new { id = mazeDb.Id })); }
static void Main(string[] args) { var mazeService = new MazeService(); mazeService.LoadMaze(); Console.Read(); }
public void TestMethod3() { var testService = new MazeService(); var mazeString = "#######################################################################################################################################################################################\r\n#A......#.....#.....#.#.....#.#...#.#.......#.....#.#...#.......#...........#...#.............#.....#.......#.........#.....#.....#...........#.#...................#.....#...........#\r\n#.#######.#.#.#.###.#.#####.#.#.#.#.#####.#.#.###.#.#######.#.###.#.#.#.#.#####.#.#########.#.###.#.#.#.#.#.#.#.#.###.#.#####.#.#.#.#.#.#.#.#.#.#.#.###.#####.#.#.#.#.#.#.#.#.#.#.#.#.#\r\n#.....#.#.....#.#...#.......#.......#...#...#.#.......#.....#.....#.........#...#...#.....#.........#.#...#.#.#.#.#...#.#...#.....#...#...#...#.#...#.#.#.#...........#.#.......#.#...#\r\n#.#####.#.#.#.#.#.###.###.#.###.#.#.#.###.#.#.#.#.#.#.###.#.#.#######.#.#.#.###.#.#.#.#.#######.#.###.###.#.#.###.#####.#.#.#.#####.###.#.#.#########.#.#.#.###.#####.#.#.#####.#.#.###\r\n#...#...#.#.#.....#...#.............#.#.......#.......#.#...#.#.........#.......#.#.....#.......#.......................#.#...#.#.#...#...#.#.#...#...#.......#.........#...#.#.....#.#\r\n#.#.###.#.#.#.#.#.#.#.#.#.###.#.#.#.#.#.###.###.###.#.#.#.#.###.###.###.#.#.#####.#.#.#.#.#.#.#.#.###.#.###########.#.#.#.#.#.#.#.###.###.#.#.#.#.#.#.#.#.#.#.#####.###.#.###.#.#####.#\r\n#...#...#...#...#.#.#.#...#...#...#...#.....#...................#...#.#.....#...........#.....#.#.#...#.#...#.........#.#.......#...........#...#.....#...#.#...............#.#.......#\r\n#.#.#.#.###.#.#.###.#######.#.#.#.#.#.#.###.#.###.#.#.#.###.#.#.#.#.#.#.#####.#.#.###.#.#.###.#.#.#.#.#.###.###.#.#.#.#####.#.###########.#.#.#.#########.#.#.###.###.###.#.#.###.#.#.#\r\n#.#.........#...#.....#.....#.#...#...#.....#...............#...#.......#.#.#.......#.#...#.....#.#.#.........#.#.........#...#...#.........#.#...#.#.#...........#.....#.......#.....#\r\n#.#.#.#.#.###.#.#.#.#.#.#.###.#########.#.#.###.#.#.#####.#####.#.#####.#.#.###.#.#.#.#.#.#.#.#.#.#.#.#.#.###.###.###.#.#.###.###.#.#.#.#.#.###.#.#.#.#.#.#####.###.#.#.#######.#.###.#\r\n#...#.........#...#.#...#.#.#...........#.#.#...........#.......#.#.#.....#...#.#.#.#...#.......#.........#...#.....#...#.....#.#.....#.#...#.....#.#...#.....#.#.#.#.............#...#\r\n#.#.###########.###.#.###.#.#####.#.#.#.###.#.###.#.#.#.#########.#.#.#####.#.#.#.#.#.#.#####.#.#.#.###.#.#.#.#.###############.#.###.#.#.#.#.#.###.###.#.#.#.#.#.#.#####.#.#.###.#.###\r\n#.....#.#...........#.#.............#.#...........#.....#.#.....#...#.#.#.#...........#.#.....#...#.....#...#.....#...........#.#.#...#.........#.#.....#...#.......#.....#...#.......#\r\n#####.#.#.#.#.#.#####.#.#####.#.#.#.#.###.#.#.###.#######.#.#.#####.#.#.#.#.#.#####.###.#.###.#.#.#.#####.#.#.###.#.###.#.###.#.#.###.#.###.###.#.#.#.#.###.#.#####.#.#.#.#####.#.###.#\r\n#.....#.#.....#.#.......#.......#.....#...#...#...............#.....#...........#.........#.....#.#.#.............#.#...#.#.....#.#...#...#...#.........#.....#...#...#...........#...#\r\n#.#.#.###.#.###.#.#.#.###.#.###.#.#.#.###.###.#.###.#.#.#.#####.#.#.#.###.#####.#####.#.#.#.###.#.###.###.#####.#.#.#.#.#.###.###.#.###.#.#.#.#.#.#####.#####.#.#.#.###.#.#.#.#####.###\r\n#...#.....#.#.......#.....#.#.....#...#...#.#.#.....#...#.#...#.#.....................#.....#.....#.....#.......#.........#...#...#...#.#.#.#...#.#.#...#...#.....#.#.......#...#.....#\r\n#####.###.###.#.#.#.#.#.#.###.#.#.#.#####.#.#.#.#.#.#######.#.#.#.#.#.#######.###.#.###.#.#.###.#.#.#.#.#.#####.#.#.#.###.#.###.###.#.###.#.###.#.#.#.#.###.#.###.###.#####.###.#.#####\r\n#.....#.....#...#.....#.#...#...#.........#...................#.....#...#.........#.....#...........#...#.#.......#.#...#...#...............#.......#...#.........#.............#.....#\r\n#.#.#.#.#######.#.#.#########.#######.###.#####.###.#.###.#.#######.#.###.#.###.###.###.#####.#####.###.#.#.#.#.#.#.#.###.#.#.#######.#.#.#.#.#.#.#.#.#####.#.#.#.#.#.#.###.#.#.###.#.#\r\n#.#.#.......#...#.#...#.......#.................#.....#...#.......#.#.....#.....#.#...#.#.....#...#.#.......#...#.....#.....#.....#.......#.....#...#.#...#.....#...#.#.#...#...#.....#\r\n###.#.#####.#.###.###.#.#.###.#.###.#####.#.#.#######.#.#########.#####.#.#.#.###.#.#.#.###.#######.#.#########.#.#.#.#.#.#.#####.###.###.###.#.#.#.#.#.#.#.###.#.#.#.#.#####.#.#.###.#\r\n#.#...#.....#.....#.#.....#...#...#.#...#...#.#.#.#.....#.....#.#.#.#.....#.................#.#.#...#...#...#.#.#.#.#.#...#...#.#.............#.#...#...#.#.#.......#.........#.#.....#\r\n#.###.#.###.#.#.#.#.###.#.#.###.#####.#.###.#.#.#.#.#.###.#.#.#.#.#.#.#.#.#.#.#####.###.#.###.#.#.###.#.#.#.#.#.#.#.#.#.###.#.#.###.#.#.#.#######.#.###.#.#.#.###.#.#.#.###.###.#.#.#.#\r\n#.#...#.....#.....#.#...#...#.......#...#.....#.#.#.....#.#...#...#...#.#.........#.....#...#.#...#...#...#.#.#.......#...#.#...#...#.#...#.....#.......#.......#.#.....#.#...#.#.....#\r\n#.#.#.#.#.#.#.###.#.###.#.#.#.###.###.#.#.###.###.#.#.#.#.###.#.#.#.#.#.#.#########.#.#.#.#.#.#######.#.###.#.#.#.#.#.#.###.#.###.#######.#.#.#.#.###.#.#.#.#.#.#.#.#####.###.#.#.###.#\r\n#.....#.....#.#...#.#.#...#.....#.....#.#...#.....#.....#.....#.#.#...#...#.#.....#.#.#...#...#.......#.....#...........#...#.#...#.......#.......#.#.#...#.#...#.#.#...........#.....#\r\n#.#####.#####.#####.#.###.#########.#.#.#.#.###.#.#.#.#.#.#.#.#####.###.#.#.#.###.#.###.#.#####.###.#####.#####.#.###.###.#.#.#.#.#.###.#.#.#####.#.#.###.###.###.#.#.#.#.#.###.###.#.#\r\n#.....#...#...#.#...#.........#.................#.#.....#.#.....#.........#...#.....#...#.#.....#.......#.......#.....#.#.#.......#.#...#.#...#.#.........#.........#...#.....#.....#.#\r\n#.###.#####.#.#.#.#.#.#######.#.#####.#########.#.#.###.#.#####.#.#####.###.#.#.#.#.###.#.#.#.#.###.#.#####.#.###.###.#.#.#.###.#.#.#.#.#.#.#.#.#.#####.#.#.###.#.#.#.#.#.#.#.###.###.#\r\n#.#...#.#.....#...#.#.#.......#.#.................#...#.....#...............#.........#...#.#.#...#.#...#...#.........#.....#...........#.#...........#.....#.#.#.#...#...#...#.#.#...#\r\n#.#.#.#.#.###.#######.#.#.#.###.#.#.#.###.#.#.###.###.#.###.#.#####.#.#.#.#.#.###.#########.#.#.#.#.#.#.#######.###.#.#.###.#.#.###.#.###.#.#.###.#.#.#.#.#.#.#.#.#.###.#####.#.###.#.#\r\n#.#.....#.....#.#.......#...#...#...#.#...#.....#.......#...#...#...#.#.#...#...#.....#.#...#...........#.........#...#.#...#...#...#...#...........#.#.#...#...........#.....#.#.....#\r\n###.#.###.#####.#.#.#.#.#.###.#.#.#####.#.#.#.#.#.#.#.###.###.#.#.###.#.###.###.#####.#.#.###.#.#.###.#.#.#.###.#####.###.#####.#.#.###.#.#####.#.#.#.#####.###.###.###.#.#.#.#.#.#.###\r\n#.........#.....#.....#...#...............#.#...#.#.#.....#.#...#...#.#...............#.......#.......#.#...#.#...........#.#.#...............#...#.........#...............#...#...#.#\r\n#.#.#.###.#.#####.#.#.#.#.#.#.###.###.###.#####.#.#####.###.#.#.###.#.###.###.#####.#####.#####.#########.###.#.#.#.#.#.#.#.#.#.#.#.#.###.#.#.###.#####.###.#####.###.#.###.###.#.#.#.#\r\n#.....#.#.............#...#.......#.#.............#.#...#.#...#...#.#.....#.#.#...#.#.....#...#...........#.....#.#.#...#...................#.....#.....#...............#.....#.#.....#\r\n#.#####.#.###.#.#######.###.###.#.#.#.###.###.#.###.#.#.#.###.#.#.#.#####.#.###.###.#########.#.#####.#.#.#.#.#.#.#.#####.#########.#.#.#.#.###.###.#.#####.#.#.###.#####.#.#.###.###.#\r\n#...#.....#.#.#.#...............#.........#.....#.......#.........#...........#...#.......#.#...#.......#.....#...#.#...#.#...#.#.....#...........#.................#...#.#.#.#...#.#.#\r\n#.#.#.#####.#.###.###.#.#.#####.#.#####.###.#.###.#.#######.#.#.###.###.###.#.#.#.#.#.#.#.#.#.#.#.#.#######.#######.#.#.###.###.#.###.#.###.#.#.#.#.#.#######.#.#.###.#.###.#####.#.#.#\r\n#.....#.#.....#...#...#.#.......#...#.............#...#.....#...#.#.......#.....#...#...#.#.....#.#...........#.......#.#...#...#.#...#.#.#.....#...............#...#.#.#...#...#.....#\r\n#####.#.#.#.###.#.###.#.#####.#######.#############.#.#.#.#.#.###.#.#.###.#.#####.#.#.#.#####.#.#.###.###.#.#.#.###.#.#.###.#.#.#.#.#.#.#.#.#.###.###.#.#######.###.#.#####.#######.###\r\n#.....#...........#.....#.....#.......#...#...#.......#.....#.#...#.#.#...#.#...#.....#.......#...#...#...#.#.#.#.....#.....#...#.#...#.......#...#...#.....#...#...#.........#.#....B#\r\n#######################################################################################################################################################################################"; var answer = testService.solveMaze(mazeString); Assert.AreEqual(416, answer.steps); }
public async Task <JsonResult> SolveMaze() { using (var ms = new MemoryStream(2048)) { await Request.Body.CopyToAsync(ms); var test = ms.ToArray(); string s = Encoding.UTF8.GetString(test, 0, test.Length); var mazeService = new MazeService(); return(Json(mazeService.solveMaze(s))); } }
public static ShowApplication CreateShowApplication() { var configuration = TestUtility.GetIConfigurationRoot(TestContext.CurrentContext.TestDirectory); var mazeServiceConfig = configuration.GetSection("MazeService"); var mazeServiceConfigOption = Options.Create <MazeServiceConfig>(mazeServiceConfig.Get <MazeServiceConfig>()); var httpClientFactory = Substitute.For <IHttpClientFactory>(); httpClientFactory.CreateClient().Returns(new HttpClient()); var mazeService = new MazeService(httpClientFactory, mazeServiceConfigOption); return(new ShowApplication(mazeService)); }
/* * After I finished the first method, I try to think this problem again * (because I like solving puzzle games as I mentioned in the interview), * and I came up with another solution. * This method will like an AI calculating the maze. * It will try to check the four directions of one point, * and then recursively check the four directions of the next point * until it finds the end point. * So I call it AIProcessor. */ private static void SecondWayToResolveMaze() { var maze = MazeService.InitialMaze(FILE_NAME); if (maze != null) { AIMazeProcessor processor = new AIMazeProcessor(); processor.SolveMaze(maze); MazeService.OutputMaze(maze.MazeMatrix, "F:\\MazeSolution2.txt"); } }
public void TestMethod1() { var testService = new MazeService(); var mazeString = "##########\r\n#A...#...#\r\n#.#.##.#.#\r\n#.#.##.#.#\r\n#.#....#B#\r\n#.#.##.#.#\r\n#....#...#\r\n##########"; var completedMaze = "##########\r\n#A@@.#...#\r\n#.#@##.#.#\r\n#.#@##.#.#\r\n#.#@@@@#@#\r\n#.#.##@#@#\r\n#....#@@@#\r\n##########\r\n"; var answer = testService.solveMaze(mazeString); var answerEncoded = Encoding.UTF8.GetBytes(answer.ToString()); var uncoded = Encoding.UTF8.GetString(answerEncoded, 0, answerEncoded.Length); Assert.AreEqual(14, answer.steps); Assert.AreEqual(completedMaze, answer.solution); }
/// <summary> /// Point d'entrée. /// </summary> /// <param name="args">Arguments de la ligne de commande</param> static void Main(string[] args) { //Console.BackgroundColor = ConsoleColor.White; Console.ForegroundColor = ConsoleColor.DarkRed; MazeService mazeDb = new MazeService(); Maze maze = mazeDb.Generate(10, 20); mazeDb.CreateMazeDb(maze); MazePrinter mazePrint = new MazePrinter(maze); mazePrint.PrintAndPlay(); Console.ReadKey(true); Console.ReadLine(); }
// Load the game and build the maze and loop for user moves public void Play() { //Reading the size Helpers.ConsoleReadInt("Enter Maze Size : ", out int MazeSize); PlayerScore = 10; MazeService.BuildMaze(MazeSize); Enterance = MazeService.GetEntranceRoom(); VisitedMaze = new Maze(MazeSize, Enterance); ResetAllowedDirections(); CurrentRoom = Enterance; VisitedMaze.ConsolePrint(CurrentRoom); while (AskToMove()) { ; } }
protected override void Initialize() { _generationAlgorithm = new PrimGenerationAlgorithm(); _mazeService = new MazeService(); _spriteService = new DogeService(); _finishLineService = new MoonRocketSpriteService(); _gameObjects = new List <List <GameObject> >(); _mazes = new List <Maze>(); for (int i = 0; i < 4; i++) { _mazes.Add(_generationAlgorithm.GenerateMaze(5 * i + 5)); } _inputService = new KeyboardInputService(); base.Initialize(); }
public ActionResult Display(int Id) { DL.Maze maze = MazeService.LireMaze(Id); MazeDisplay mazeDisplay = new MazeDisplay(); mazeDisplay.Id = maze.Id; mazeDisplay.Length = maze.Length; mazeDisplay.Width = maze.Width; mazeDisplay.Entree = maze.Entree; mazeDisplay.Sortie = maze.Sortie; List <DL.MazeTile> mazeTile = MazeService.LireMazeTile(Id); mazeDisplay.MazeTile = mazeTile; return(View(mazeDisplay)); }
// Move action handler // It uses the Maze integration service for fetching the room data public void Move(int id, char direction) { string dir = direction.ToString().ToUpper(); var RoomId = MazeService.GetRoom(id, direction); // Null is an edge if (RoomId == null) { DisallowDirection(dir); return; } CurrentRoom = RoomId.Value; ResetAllowedDirections(); var RoomDesc = MazeService.GetDescription(CurrentRoom); var isTrap = MazeService.CausesInjury(CurrentRoom); var isTreasure = MazeService.HasTreasure(CurrentRoom); PlayerSteps++; Console.WriteLine("[Room Description: {0} ]", RoomDesc); if (isTrap) { VisitedMaze.SetRoom(CurrentRoom, 'O'); Console.WriteLine("You trapped and your score has been decreased by one."); PlayerScore--; } else if (isTreasure) { VisitedMaze.SetRoom(CurrentRoom, '€'); Won = true; } else if (CurrentRoom != Enterance) { VisitedMaze.SetRoom(CurrentRoom, 'X'); } }
} // public MazeWebController() { MazeService = new MazeService(); }
public MazeController(ILogger <MazeController> logger, IAuthService authService, MazeService mazeService) { _logger = logger; _authService = authService; _mazeService = mazeService; }