Пример #1
0
        /// <summary>
        /// Returns a List containing all the possible (valid) successors of a gives AState
        /// </summary>
        /// <param name="state"></param>
        /// <returns> List of successors  </returns>
        public List <AState> getAllSuccessors(AState state)
        {
            List <AState> successors = new List <AState>();
            MazeState     mState     = (MazeState)state;
            int           col        = mState.getX();
            int           row        = mState.getY();
            int           floor      = mState.getZ();

            //Right (Col ++)
            if (col + 1 < m_maze3d.getWidth() && m_maze3d.isPath(col + 1, row, floor))
            {
                successors.Add(new MazeState(state, col + 1, row, floor));
            }
            //Left (Col --)
            if (col - 1 >= 0 && m_maze3d.isPath(col - 1, row, floor))
            {
                successors.Add(new MazeState(state, col - 1, row, floor));
            }
            //Up (Row ++)
            if (row + 1 < m_maze3d.getHeight() && m_maze3d.isPath(col, row + 1, floor))
            {
                successors.Add(new MazeState(state, col, row + 1, floor));
            }
            //Down (Row --)
            if (row - 1 >= 0 && m_maze3d.isPath(col, row - 1, floor))
            {
                successors.Add(new MazeState(state, col, row - 1, floor));
            }
            //Ascend (Floor ++)
            if (floor + 1 < m_maze3d.getLevels() && m_maze3d.isPath(col, row, floor + 1))
            {
                successors.Add(new MazeState(state, col, row, floor + 1));
            }
            //Descend (Floor --)
            if (floor - 1 >= 0 && m_maze3d.isPath(col, row, floor - 1))
            {
                successors.Add(new MazeState(state, col, row, floor - 1));
            }
            return(successors);
        }