Пример #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);
 }
Пример #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);
        }
Пример #3
0
        private void Awake()
        {
            var board = GameObject.FindWithTag("Board");

            playerManager = board.GetComponent <PlayerManager>();
            maze          = board.GetComponent <Maze.Maze>();
        }
Пример #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);
        }
Пример #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;
 }
Пример #6
0
        /// <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);
            }
        }
Пример #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();
        }
Пример #8
0
        /// <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);
        }
Пример #9
0
        void Start()
        {
            _particleSystem = GetComponent <ParticleSystem>();
            maze            = SecondaryFunctions.GetMaze()?.GetComponent <Maze.Maze>();

            if (maze == null)
            {
                return;
            }

            InitParticleSystem();
        }
Пример #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();
        }
Пример #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);
        }
Пример #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);
        }
Пример #13
0
 // CONSTRUCTORS
 public AStar(Maze.Maze maze, byte delay = 25)
     : base(maze, delay)
 {
     this.openSet   = new HashSet <ACell>();
     this.closedSet = new HashSet <Cell>();
 }
Пример #14
0
 public void CreateMazeSuccess()
 {
     Maze.Maze maze = new Maze.Maze(3, 3);
     Assert.AreNotEqual(0, maze.Grid.Length);
 }
Пример #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>();
 }
Пример #17
0
 public SendMazeRequest(Guid userID, Guid gameID, Maze.Maze maze = null) : base()
 {
     Maze   = maze;
     UserID = userID;
     GameID = gameID;
 }
Пример #18
0
 public BestFirstSearch(Maze.Maze maze, byte delay = 25) : base(maze, delay)
 {
     container = new PriorityQueue <Cell>(new CellComparer(CellComparer.CellComparerType.pointDistance, goal));
 }
Пример #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>();
 }
Пример #21
0
        static void Main(string[] args)
        {
            var maze = new Maze.Maze(15, 7, 3);

            maze.Print();
        }
Пример #22
0
 // CONSTRUCTORS
 public DijkstrasAlgorithm(Maze.Maze maze, byte delay = 25)
     : base(maze, delay)
 {
     this.openSet   = new HashSet <DCell>();
     this.closedSet = new HashSet <Cell>();
 }
Пример #23
0
        /// <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));
        }
Пример #24
0
 private void Awake()
 {
     maze        = GetComponent <Maze.Maze>();
     itemManager = GetComponent <ItemManager>();
 }