示例#1
0
        /// <summary>
        /// get state position - call to getState (state pool).
        /// </summary>
        /// <param name="row">in row</param>
        /// <param name="col">in col</param>
        /// <returns>state at positon[row,col]</returns>
        private State <MazeLib.Position> CreatePos(int row, int col)
        {
            MazeLib.Position         tempPos   = new MazeLib.Position(row, col);
            State <MazeLib.Position> tempState = State <MazeLib.Position> .StatePool.GetState(tempPos);

            return(tempState);
        }
示例#2
0
        /// <summary>
        /// check his all relevant niegbours
        /// </summary>
        /// <param name="s">check s neighbors</param>
        /// <returns> the list of them</returns>
        public List <State <Position> > getAllPossibleStates(State <Position> s)
        {
            List <State <MazeLib.Position> > myNeigbours = new List <State <MazeLib.Position> >();

            // up
            if ((s.getState().Row - 1 >= 0) && (myMaze[s.getState().Row - 1, s.getState().Col] == 0))
            {
                MazeLib.Position         upPosition = new MazeLib.Position(s.getState().Row - 1, s.getState().Col);
                State <MazeLib.Position> up         = new State <MazeLib.Position>(upPosition);
                up.CameFrom = s;
                myNeigbours.Add(up);
            }
            //right
            if ((s.getState().Col + 1 < myMaze.Cols) && (myMaze[s.getState().Row, s.getState().Col + 1] == 0))
            {
                MazeLib.Position         rightPosition = new MazeLib.Position(s.getState().Row, s.getState().Col + 1);
                State <MazeLib.Position> right         = new State <MazeLib.Position>(rightPosition);
                right.CameFrom = s;
                myNeigbours.Add(right);
            }
            // down
            if ((s.getState().Row + 1 < myMaze.Rows) && (myMaze[s.getState().Row + 1, s.getState().Col] == 0))
            {
                Position         downPosition = new Position(s.getState().Row + 1, s.getState().Col);
                State <Position> down         = new State <Position>(downPosition);
                down.CameFrom = s;
                myNeigbours.Add(down);
            }
            //left
            if ((s.getState().Col - 1 >= 0) && (myMaze[s.getState().Row, s.getState().Col - 1] == 0))
            {
                Position         leftPosition = new Position(s.getState().Row, s.getState().Col - 1);
                State <Position> left         = new State <Position>(leftPosition);
                left.CameFrom = s;
                myNeigbours.Add(left);
            }
            return(myNeigbours);
        }
示例#3
0
        /// <summary>
        /// returning a list of the possible states for the given state
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public List <State <MazeLib.Position> > GetAllPossibleStates(State <MazeLib.Position> s)
        {
            List <State <MazeLib.Position> > possibleStates = new List <State <MazeLib.Position> >();

            if (s.Getstate().Col + 1 < maze.Cols && maze[s.Getstate().Row, s.Getstate().Col + 1] == CellType.Free)
            {
                MazeLib.Position         position = new MazeLib.Position(s.Getstate().Row, s.Getstate().Col + 1);
                State <MazeLib.Position> state    = State <MazeLib.Position> .StatePool.GetState(position);

                possibleStates.Add(state);
            }

            if (s.Getstate().Row - 1 >= 0 && maze[s.Getstate().Row - 1, s.Getstate().Col] == CellType.Free)
            {
                MazeLib.Position         position = new MazeLib.Position(s.Getstate().Row - 1, s.Getstate().Col);
                State <MazeLib.Position> state    = State <MazeLib.Position> .StatePool.GetState(position);

                possibleStates.Add(state);
            }

            if (s.Getstate().Col - 1 >= 0 && maze[s.Getstate().Row, s.Getstate().Col - 1] == CellType.Free)
            {
                MazeLib.Position         position = new MazeLib.Position(s.Getstate().Row, s.Getstate().Col - 1);
                State <MazeLib.Position> state    = State <MazeLib.Position> .StatePool.GetState(position);

                possibleStates.Add(state);
            }

            if (s.Getstate().Row + 1 < maze.Rows && maze[s.Getstate().Row + 1, s.Getstate().Col] == CellType.Free)
            {
                MazeLib.Position         position = new MazeLib.Position(s.Getstate().Row + 1, s.Getstate().Col);
                State <MazeLib.Position> state    = State <MazeLib.Position> .StatePool.GetState(position);

                possibleStates.Add(state);
            }

            return(possibleStates);
        }
示例#4
0
        public List <State <MazeLib.Position> > getAllPossibleStates(State <MazeLib.Position> s)
        {
            List <State <MazeLib.Position> > possibleStates = new List <State <MazeLib.Position> >();

            if (maze[s.getstate().Row, s.getstate().Col + 1] == 0)
            {
                MazeLib.Position         position = new MazeLib.Position(s.getstate().Row, s.getstate().Col + 1);
                State <MazeLib.Position> state    = State <MazeLib.Position> .StatePool.getState(position);

                possibleStates.Add(state);
            }

            if (maze[s.getstate().Row - 1, s.getstate().Col] == 0)
            {
                MazeLib.Position         position = new MazeLib.Position(s.getstate().Row - 1, s.getstate().Col);
                State <MazeLib.Position> state    = State <MazeLib.Position> .StatePool.getState(position);

                possibleStates.Add(state);
            }

            if (maze[s.getstate().Row, s.getstate().Col - 1] == 0)
            {
                MazeLib.Position         position = new MazeLib.Position(s.getstate().Row, s.getstate().Col - 1);
                State <MazeLib.Position> state    = State <MazeLib.Position> .StatePool.getState(position);

                possibleStates.Add(state);
            }

            if (maze[s.getstate().Row + 1, s.getstate().Col] == 0)
            {
                MazeLib.Position         position = new MazeLib.Position(s.getstate().Row + 1, s.getstate().Col);
                State <MazeLib.Position> state    = State <MazeLib.Position> .StatePool.getState(position);

                possibleStates.Add(state);
            }

            return(possibleStates);
        }