Exemple #1
0
 public void CreateAdjacentsSuccess()
 {
     Maze.Maze maze = new Maze.Maze(5, 5);
     Common common = new Common();
     common.CreateAdjacents(maze);
     Assert.AreNotEqual(0, maze.Grid[0, 0].Adjacents.Count);
 }
Exemple #2
0
        public void FindEndRecursiveBacktrackerSuccess()
        {
            Maze.Maze maze   = new Maze.Maze(10, 10);
            Common    common = new Common();

            common.CreateAdjacents(maze);
            maze.SetMazeCreationStrategy(new RecursiveBacktrackingAlgorithm(maze));

            string output = System.Environment.NewLine;

            for (int i = maze.Rows - 1; i >= 0; i--)
            {
                for (int j = maze.Columns - 1; j >= 0; j--)
                {
                    if (maze.Grid[i, j].CellState == CELL_STATE.OPEN)
                    {
                        output += "|O|";
                    }
                    else
                    {
                        output += "|X|";
                    }
                }
                output += System.Environment.NewLine;
            }

            Logger.Instance.Log(output);

            Assert.AreEqual(1, 1);
        }
Exemple #3
0
        private void Awake()
        {
            var board = GameObject.FindWithTag("Board");

            playerManager = board.GetComponent <PlayerManager>();
            maze          = board.GetComponent <Maze.Maze>();
        }
Exemple #4
0
        public void CreateAdjacentsSuccess()
        {
            Maze.Maze maze   = new Maze.Maze(5, 5);
            Common    common = new Common();

            common.CreateAdjacents(maze);
            Assert.AreNotEqual(0, maze.Grid[0, 0].Adjacents.Count);
        }
Exemple #5
0
 // CONSTRUCTORS
 public SearchAbstract(Maze.Maze maze, byte delay)
 {
     this.maze    = maze;
     this.start   = maze.Start;
     this.goal    = maze.End;
     this.delay   = delay;
     this.lastPos = null;
 }
        /// <summary>
        ///     .ctor
        /// </summary>
        /// <param name="maze"></param>
        /// <param name="rooms"></param>
        /// <param name="aisles"></param>
        private void Construct(Maze.Maze maze, IReadOnlyDictionary <int, RoomView> rooms, IReadOnlyDictionary <int, AisleView> aisles)
        {
            Maze   = maze;
            Rooms  = rooms;
            Aisles = aisles;

            foreach (var room in rooms.Values)
            {
                room.transform.SetParent(transform);
            }
        }
Exemple #7
0
        static void Main(string[] args)
        {
            var maze = new Maze.Maze(new MapResources());

            maze.DrawMaze();

            var explorer = new Explorer(maze, new MazeConsole());

            Console.SetCursorPosition(explorer.CurrentPosition.PositionX, explorer.CurrentPosition.PositionY);

            var direction = Direction.Up;

            while (!explorer.Finished)
            {
                var command = Console.ReadKey().Key;

                switch (command)
                {
                case ConsoleKey.DownArrow:
                    direction = Direction.Down;
                    break;

                case ConsoleKey.UpArrow:
                    direction = Direction.Up;
                    break;

                case ConsoleKey.LeftArrow:
                    direction = Direction.Left;
                    break;

                case ConsoleKey.RightArrow:
                    direction = Direction.Right;
                    break;
                }


                explorer.MoveTowards(direction);
            }

            explorer.PrintPathHistory();
            Console.WriteLine();
            Console.WriteLine("AutoExplore will start now! Please press enter");
            Console.ReadLine();
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.White;

            explorer = new Explorer(maze, new MazeConsole());
            maze.DrawMaze();
            Console.SetCursorPosition(explorer.CurrentPosition.PositionX, explorer.CurrentPosition.PositionY);

            explorer.AutoExploreMaze();

            Console.WriteLine();
        }
        /// <summary>
        /// 迷宮オブジェクト作成
        /// </summary>
        /// <param name="maze"></param>
        /// <param name="rooms"></param>
        /// <param name="aisles"></param>
        /// <returns></returns>
        public static MazeView Create(
            Maze.Maze maze,
            IReadOnlyDictionary <int, RoomView> rooms,
            IReadOnlyDictionary <int, AisleView> aisles
            )
        {
            var @this = new GameObject("MazeView").AddComponent <MazeView>();

            @this.Construct(maze, rooms, aisles);

            return(@this);
        }
        void Start()
        {
            _particleSystem = GetComponent <ParticleSystem>();
            maze            = SecondaryFunctions.GetMaze()?.GetComponent <Maze.Maze>();

            if (maze == null)
            {
                return;
            }

            InitParticleSystem();
        }
Exemple #10
0
        public override void Init()
        {
            _saveSystem = new SaveSystem();
            if (!_continue)
            {
                _maze = new Maze.Maze(this);
                _maze.CreateMaze(out var player);

                _player = Entity.CreateEntity <Player>("Player", player, this);
                _player.SetTreasures(_maze.TreasuresNum);

                _saveSystem.SaveFile.LevelSaveData.SaveLevel(Grid);
            }
            else
            {
                foreach (var point in _saveSystem.SaveFile.LevelSaveData.BlockPositions)
                {
                    Entity.CreateEntity <MazeBlock>($"Block", point.Point, this);
                }

                var t = 0;
                foreach (var point in _saveSystem.SaveFile.LevelSaveData.TreasurePositions)
                {
                    Entity.CreateEntity <Treasure>("Treasure", point.Point, this);
                    t++;
                }
                foreach (var point in _saveSystem.SaveFile.LevelSaveData.StonePositions)
                {
                    Entity.CreateEntity <Stone>("Stone", point.Point, this);
                }

                _player = Entity.CreateEntity <Player>("Player", _saveSystem.SaveFile.LevelSaveData.PlayerPosition.Point, this);
                _player.SetTreasures(t);
            }
            _clock = new Stopwatch();
            _clock.Start();
        }
Exemple #11
0
        public void FindEndSuccess()
        {
            Maze.Maze maze = new Maze.Maze(10, 10);
            Common common = new Common();
            common.CreateAdjacents(maze);
            maze.SetMazeCreationStrategy(new PrimsAlgorithm(maze));

            string output = System.Environment.NewLine;
            for (int i = maze.Rows-1; i >= 0; i--)
            {
                for (int j = maze.Columns-1; j >= 0; j--)
                {
                    if (maze.Grid[i, j].CellState == CELL_STATE.OPEN)
                        output += "|O|";
                    else
                        output += "|X|";
                }
                output += System.Environment.NewLine;
            }

            Logger.Instance.Log(output);

            Assert.AreEqual(1, 1);
        }
Exemple #12
0
        public void TestInitialize()
        {
            _mapResources = Substitute.For <IMapResources>();
            var map = new Map()
            {
                Columns     = 4,
                Rows        = 8,
                MapDraw     = "",
                MappedArray = new char[8, 4] {
                    { 'X', 'X', 'X', 'X' },
                    { 'S', ' ', 'X', 'X' },
                    { 'X', ' ', 'X', 'X' },
                    { 'X', ' ', ' ', 'X' },
                    { 'X', 'X', ' ', 'X' },
                    { 'X', ' ', ' ', 'X' },
                    { 'X', ' ', 'X', 'X' },
                    { 'X', 'F', 'X', 'X' }
                }
            };


            _mapResources.GetMap().Returns(map);
            _maze = new Maze.Maze(_mapResources);
        }
Exemple #13
0
 // CONSTRUCTORS
 public AStar(Maze.Maze maze, byte delay = 25)
     : base(maze, delay)
 {
     this.openSet   = new HashSet <ACell>();
     this.closedSet = new HashSet <Cell>();
 }
Exemple #14
0
 public void CreateMazeSuccess()
 {
     Maze.Maze maze = new Maze.Maze(3, 3);
     Assert.AreNotEqual(0, maze.Grid.Length);
 }
Exemple #15
0
 public void CreateMazeSuccess()
 {
     Maze.Maze maze = new Maze.Maze(3, 3);
     Assert.AreNotEqual(0, maze.Grid.Length);
 }
 public DepthFirstSearch(Maze.Maze maze, byte delay = 25) : base(maze, delay)
 {
     container = new Stack <Cell>();
 }
Exemple #17
0
 public SendMazeRequest(Guid userID, Guid gameID, Maze.Maze maze = null) : base()
 {
     Maze   = maze;
     UserID = userID;
     GameID = gameID;
 }
Exemple #18
0
 public BestFirstSearch(Maze.Maze maze, byte delay = 25) : base(maze, delay)
 {
     container = new PriorityQueue <Cell>(new CellComparer(CellComparer.CellComparerType.pointDistance, goal));
 }
Exemple #19
0
 // CONSTRUCTORS
 public FirstSearch(Maze.Maze maze, byte delay)
     : base(maze, delay)
 {
 }
 public BreadthFirstSearch(Maze.Maze maze, byte delay = 25) : base(maze, delay)
 {
     container = new Queue <Cell>();
 }
Exemple #21
0
        static void Main(string[] args)
        {
            var maze = new Maze.Maze(15, 7, 3);

            maze.Print();
        }
Exemple #22
0
 // CONSTRUCTORS
 public DijkstrasAlgorithm(Maze.Maze maze, byte delay = 25)
     : base(maze, delay)
 {
     this.openSet   = new HashSet <DCell>();
     this.closedSet = new HashSet <Cell>();
 }
        /// <summary>
        /// 迷宮を実体化する
        /// </summary>
        /// <param name="maze"></param>
        /// <param name="mazeSettings"></param>
        /// <returns></returns>
        private MazeView ConstructMazeView(Maze.Maze maze, MazeSettings mazeSettings)
        {
            var viewBuilder = _mazeViewBuilderFactory.Create(maze);

            return(viewBuilder.Construct(mazeSettings));
        }
Exemple #24
0
 private void Awake()
 {
     maze        = GetComponent <Maze.Maze>();
     itemManager = GetComponent <ItemManager>();
 }