예제 #1
0
        private void markWalls(MazeSockets.AvailableSteps i_Options)
        {
            Position temp;
            Position current = this.m_CurrentPosition;


            if (!i_Options.Up)
            {
                temp = current;
                temp.StepUp();
                getCellFromPosition().State = eCellState.Wall;
            }

            if (!i_Options.Down)
            {
                temp = current;
                temp.StepDown();
                getCellFromPosition().State = eCellState.Wall;
            }

            if (!i_Options.Left)
            {
                temp = current;
                temp.StepLeft();
                getCellFromPosition().State = eCellState.Wall;
            }

            if (!i_Options.Right)
            {
                temp = current;
                temp.StepRight();
                getCellFromPosition().State = eCellState.Wall;
            }
        }
예제 #2
0
        private void recursiveStep(MazeCell i_Source)
        {
            this.NumberOfCalls++;

            Position currentPos  = this.r_Socket.GetCurrentPosition();
            MazeCell currentCell = getCellFromPosition(currentPos);

            currentCell.State = eCellState.Visited;
            MazeSockets.AvailableSteps steps = this.r_Socket.GetPossibleSteps();
            markWalls(steps);
            fillCurrentMessages();
            Position tempCur = currentPos;

            if (steps.Up)
            {
                if (StepUp())
                {
                    recursiveStep(currentCell);
                    steps = this.r_Socket.GetPossibleSteps();
                    markWalls(steps);
                }
            }

            if (steps.Down)
            {
                if (StepDown())
                {
                    recursiveStep(currentCell);
                    steps = this.r_Socket.GetPossibleSteps();
                    markWalls(steps);
                }
            }

            if (steps.Left)
            {
                if (StepLeft())
                {
                    recursiveStep(currentCell);
                    steps = this.r_Socket.GetPossibleSteps();
                    markWalls(steps);
                }
            }

            if (steps.Right)
            {
                if (StepRight())
                {
                    recursiveStep(currentCell);
                    steps = this.r_Socket.GetPossibleSteps();
                    markWalls(steps);
                }
            }

            if (i_Source != null)
            {
                returnStep(i_Source);
            }

            this.NumberOfCalls--;
        }
예제 #3
0
        private void recursiveStep(MazeCell i_Source)
        {
            if (!this.m_KeepWalking)
            {
                Console.WriteLine("ret");
                return;
            }

            //this.m_CurrentPosition = this.r_Socket.GetCurrentPosition();
            Console.WriteLine(this.m_CurrentPosition.ToString());
            MazeCell currentCell = getCellFromPosition();

            currentCell.State = eCellState.Visited;
            MazeSockets.AvailableSteps steps = this.r_Socket.GetPossibleSteps();
            markWalls(steps);
            fillCurrentMessages(currentCell);
            Position tempCur = this.m_CurrentPosition;

            if (steps.Up && this.m_KeepWalking)
            {
                if (StepUp())
                {
                    recursiveStep(currentCell);
                }
            }

            if (steps.Down && this.m_KeepWalking)
            {
                if (StepDown())
                {
                    recursiveStep(currentCell);
                }
            }

            if (steps.Left && this.m_KeepWalking)
            {
                if (StepLeft())
                {
                    recursiveStep(currentCell);
                }
            }

            if (steps.Right && this.m_KeepWalking)
            {
                if (StepRight())
                {
                    recursiveStep(currentCell);
                }
            }

            if (i_Source != null && this.m_KeepWalking)
            {
                returnStep(i_Source);
            }
        }