Ejemplo n.º 1
0
  @Override
  public List<SearchNode<RobotPuzzle, RobotMove>> getSuccessors(
      SearchNode<RobotPuzzle, RobotMove> s) {
    ArrayList<SearchNode<RobotPuzzle, RobotMove>> successors =
        new ArrayList<SearchNode<RobotPuzzle, RobotMove>>();

    RobotPuzzle current = s.getState();

    for (int i = 0; i < 4; i++) {
      if (isPossibleMove(new RobotMove(i))) {
        RobotPuzzle successor = new RobotPuzzle(current);
        successor.performAction(new RobotMove(i));
        successors.add(new SearchNode<RobotPuzzle, RobotMove>(s, new RobotMove(i), successor));
      }
    }

    return successors;
  }