Ejemplo n.º 1
0
        public GameAreaHandler(Guid playerId, WorldState state, SimpleMaze game, MazePlayer mazePlayer)
        {
            this.playerId = playerId;
            this.state    = state;
            this.game     = game;

            this.mazePlayer = mazePlayer;;
        }
Ejemplo n.º 2
0
        public void SimpleMaze3()
        {
            // Arrange
            IMaze maze = SimpleMaze.CreateSimpleMaze3();

            // Act
            var(foundSolution, _) = SimpleMazeSolver.SimpleSolver(maze);

            // Assert
            Assert.False(foundSolution);
        }
Ejemplo n.º 3
0
        private void StartGame(Guid firstPlayerId, Guid secondPlayerId)
        {
            var firstPlayer  = new MazePlayer(state.Players[firstPlayerId]);
            var secondPlayer = new MazePlayer(state.Players[secondPlayerId]);

            var game = new SimpleMaze(state, firstPlayer, secondPlayer);

            state.Games.Add(game.GameId, game);

            state.Players[firstPlayer.Id].SetHandler(new GameAreaHandler(firstPlayer.Id, state, game, firstPlayer));
            state.Players[secondPlayer.Id].SetHandler(new GameAreaHandler(secondPlayer.Id, state, game, secondPlayer));
        }
Ejemplo n.º 4
0
        public void SimpleMaze2()
        {
            // Arrange
            IMaze maze = SimpleMaze.CreateSimpleMaze2();

            // Act
            var(foundSolution, solutionPath) = SimpleMazeSolver.SimpleSolver(maze);
            maze.SavePath(solutionPath, "../../../../images/SimpleMaze2_solution.jpg");

            // Assert
            Assert.True(foundSolution);
        }
Ejemplo n.º 5
0
        public void SimpleMaze1_AStar()
        {
            // Arrange
            var maze  = SimpleMaze.CreateSimpleMaze1();
            var graph = MazeSolverUtility.CreateGraph(maze);

            // Act
            IEnumerable <Point> solutionPath = Astar.Astar.Run(graph).NodeToPoint();

            maze.SavePath(solutionPath, "../../../../images/SimpleMaze1_A*_solution.jpg");

            // Assert
            Assert.Equal(solutionPath, new List <Point>
            {
                new Point {
                    X = 3, Y = 0
                },
                new Point {
                    X = 3, Y = 1
                },
                new Point {
                    X = 1, Y = 1
                },
                new Point {
                    X = 1, Y = 3
                },
                new Point {
                    X = 3, Y = 3
                },
                new Point {
                    X = 3, Y = 5
                },
                new Point {
                    X = 5, Y = 5
                },
                new Point {
                    X = 5, Y = 8
                },
                new Point {
                    X = 7, Y = 8
                },
                new Point {
                    X = 7, Y = 9
                }
            });
        }