/// <summary> /// get all the Succesors for the current state /// </summary> /// <param name="state"></param> /// <returns>list of Succesors</returns> public List <AState> GetAllSuccessors(AState state) { List <AState> successors = new List <AState>(); MazeState m = state as MazeState; Position down = new Position(m.Position.X + 1, m.Position.Y, m.Position.Z); // create down position checkDown(down, successors, m, state); // check for the down position Position up = new Position(m.Position.X - 1, m.Position.Y, m.Position.Z); // create up position checkUp(up, successors, m, state); // check for the up position Position right = new Position(m.Position.X, m.Position.Y + 1, m.Position.Z); // create right position checkRight(right, successors, m, state); // check for the right position Position left = new Position(m.Position.X, m.Position.Y - 1, m.Position.Z); // create left position checkLeft(left, successors, m, state); // check for the up position Position UpinZ = new Position(m.Position.X, m.Position.Y, m.Position.Z + 1); if (checkIfInLimits(UpinZ) == true && checkIfThereIsAWall(UpinZ) == false) // up in layers in maze { AState n_Astate = new MazeState(state, UpinZ); // add to succersos if it in limits and if not wall successors.Add(n_Astate); } Position DowninZ = new Position(m.Position.X, m.Position.Y, m.Position.Z - 1); if (checkIfInLimits(DowninZ) == true && checkIfThereIsAWall(DowninZ) == false) // down in layers in maze { AState n_Astate = new MazeState(state, DowninZ); // add to succersos if it in limits and if not wall successors.Add(n_Astate); } return(successors); }
/// <summary> /// check if there is a way in right position /// </summary> /// <param name="down"> position in maze</param> /// <param name="successors">list of succesors</param> /// <param name="m">maze state</param> /// <param name="state"> state</param> public void checkRight(Position right, List <AState> successors, MazeState m, AState state) { if (checkIfInLimits(right) == true) // check if in limits of the maze { if (checkIfThereIsAWall(right) == false) // check if it is a wall { Position rightCell = new Position(m.Position.X, m.Position.Y + 2, m.Position.Z); // cell that it is part of the options in the maze if (checkIfInLimits(rightCell) == true) { AState n_Astate = new MazeState(state, rightCell); // add to succersos if it in limits and if not wall successors.Add(n_Astate); } } } }
/// <summary> /// get the startState of the maze /// </summary> /// <returns>startStateOf the maze</returns> public AState GetStartState() { AState start = new MazeState(null, m_maze.getStartPosition()); return(start); }
/// <summary> /// get the goalState of the maze /// </summary> /// <returns>goal State of the maze</returns> public AState GetGoalState() { AState goal = new MazeState(null, m_maze.getGoalPosition()); return(goal); }