コード例 #1
0
ファイル: UserController.cs プロジェクト: DorianPopa/aMAZEing
 public UserController(ILogger <UserController> logger, IAuthService authService, UserService userService, MazeService mazeService)
 {
     _logger      = logger;
     _authService = authService;
     _userService = userService;
     _mazeService = mazeService;
 }
コード例 #2
0
ファイル: MazeServiceTests.cs プロジェクト: OliDow/Maze
        public void Setup()
        {
            _mazeService = new MazeService();

            string dir = Path.GetDirectoryName(Path.GetDirectoryName(Directory.GetCurrentDirectory()));
            _filePath = Path.Combine(dir, "ExampleMaze.txt");
        }
コード例 #3
0
ファイル: MazeWebController.cs プロジェクト: KevinAdrar/maze
        public ActionResult Generate()
        {
            Maze maze = MazeService.Generate(10, 20);

            DL.Maze mazeDb = MazeService.CreateMazeDb(maze);
            return(RedirectToAction("Display", new { id = mazeDb.Id }));
        }
コード例 #4
0
        static void Main(string[] args)
        {
            var mazeService = new MazeService();

            mazeService.LoadMaze();
            Console.Read();
        }
コード例 #5
0
ファイル: UnitTest1.cs プロジェクト: netKnapp/solveMaze
        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);
        }
コード例 #6
0
        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)));
            }
        }
コード例 #7
0
        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));
        }
コード例 #8
0
        /*
         * 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");
            }
        }
コード例 #9
0
ファイル: UnitTest1.cs プロジェクト: netKnapp/solveMaze
        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);
        }
コード例 #10
0
        /// <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();
        }
コード例 #11
0
ファイル: GameClient.cs プロジェクト: eramax/MazeGame
 // 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())
     {
         ;
     }
 }
コード例 #12
0
        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();
        }
コード例 #13
0
ファイル: MazeWebController.cs プロジェクト: KevinAdrar/maze
        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));
        }
コード例 #14
0
ファイル: GameClient.cs プロジェクト: eramax/MazeGame
        // 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');
            }
        }
コード例 #15
0
ファイル: MazeWebController.cs プロジェクト: KevinAdrar/maze
        }                                         //

        public MazeWebController()
        {
            MazeService = new MazeService();
        }
コード例 #16
0
ファイル: MazeController.cs プロジェクト: DorianPopa/aMAZEing
 public MazeController(ILogger <MazeController> logger, IAuthService authService, MazeService mazeService)
 {
     _logger      = logger;
     _authService = authService;
     _mazeService = mazeService;
 }