Examples of XYLocation


Examples of aima.core.util.datastructure.XYLocation

  public List<GameState> getSuccessorStates(GameState state) {
    GameState temp = presentState;
    List<GameState> retVal = new ArrayList<GameState>();
    int parentLevel = getLevel(state);
    for (int i = 0; i < getMoves(state).size(); i++) {
      XYLocation loc = (XYLocation) getMoves(state).get(i);

      GameState aState = makeMove(state, loc);
      aState.put("moveMade", loc);
      aState.put("level", new Integer(parentLevel + 1));
      retVal.add(aState);
View Full Code Here

Examples of aima.core.util.datastructure.XYLocation

    return retVal;
  }

  @Override
  public GameState makeMove(GameState state, Object o) {
    XYLocation loc = (XYLocation) o;
    return makeMove(state, loc.getXCoOrdinate(), loc.getYCoOrdinate());
  }
View Full Code Here

Examples of aima.core.util.datastructure.XYLocation

    return presentState;
  }

  public GameState getMove(GameState state, int x, int y) {
    GameState retVal = null;
    XYLocation loc = new XYLocation(x, y);
    List<XYLocation> moves = getMoves(state);
    List<XYLocation> newMoves = new ArrayList<XYLocation>(moves);
    if (moves.contains(loc)) {
      int index = newMoves.indexOf(loc);
      newMoves.remove(index);
View Full Code Here

Examples of aima.core.util.datastructure.XYLocation

  public void printPossibleMoves() {
    System.out.println("Possible moves");

    List<XYLocation> moves = getMoves(presentState);
    for (int i = 0; i < moves.size(); i++) {
      XYLocation moveLoc = (XYLocation) moves.get(i);
      GameState newState = getMove(presentState,
          moveLoc.getXCoOrdinate(), moveLoc.getYCoOrdinate());
      System.out.println("utility = " + computeUtility(newState));
      System.out.println("");
    }

  }
View Full Code Here

Examples of aima.core.util.datastructure.XYLocation

  public List<XYLocation> getUnMarkedPositions() {
    List<XYLocation> retVal = new ArrayList<XYLocation>();
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (isEmpty(i, j)) {
          retVal.add(new XYLocation(i, j));
        }
      }

    }
    return retVal;
View Full Code Here

Examples of aima.core.util.datastructure.XYLocation

    @Override
    public void actionPerformed(ActionEvent ae) {
      for (int i = 0; i < currSize * currSize; i++) {
        if (ae.getSource() == squareButtons[i]) {
          NQueensController contr = (NQueensController) getController();
          XYLocation loc = new XYLocation(i % currSize, i / currSize);
          contr.modifySquare(loc);
        }
      }
    }
View Full Code Here

Examples of aima.core.util.datastructure.XYLocation

        break;
      }
      env = new NQueensEnvironment(board);
      if (selState.getValue(NQueensFrame.PROBLEM_SEL) == 1)
        for (int i = 0; i < board.getSize(); i++)
          board.addQueenAt(new XYLocation(i, 0));
      boardDirty = false;
      agent = null;
      frame.getEnvView().setEnvironment(env);
    }
View Full Code Here

Examples of aima.core.util.datastructure.XYLocation

     */
    @Override
    public EnvironmentState executeAction(Agent agent, Action action) {
      if (action instanceof QueenAction) {
        QueenAction act = (QueenAction) action;
        XYLocation loc = new XYLocation(act.getX(), act.getY());
        if (act.getName() == QueenAction.PLACE_QUEEN)
          board.addQueenAt(loc);
        else if (act.getName() == QueenAction.REMOVE_QUEEN)
          board.removeQueenFrom(loc);
        else if (act.getName() == QueenAction.MOVE_QUEEN)
View Full Code Here

Examples of aima.core.util.datastructure.XYLocation

    @Override
    public void actionPerformed(ActionEvent ae) {
      for (int i = 0; i < 9; i++) {
        if (ae.getSource() == squareButtons[i]) {
          EightPuzzleController contr = (EightPuzzleController) getController();
          XYLocation locGap = ((EightPuzzleEnvironment) env)
              .getBoard().getLocationOf(0);
          if (locGap.getXCoOrdinate() == i / 3) {
            if (locGap.getYCoOrdinate() == i % 3 - 1)
              contr.executeUserAction(EightPuzzleBoard.RIGHT);
            else if (locGap.getYCoOrdinate() == i % 3 + 1)
              contr.executeUserAction(EightPuzzleBoard.LEFT);
          } else if (locGap.getYCoOrdinate() == i % 3) {
            if (locGap.getXCoOrdinate() == i / 3 - 1)
              contr.executeUserAction(EightPuzzleBoard.DOWN);
            else if (locGap.getXCoOrdinate() == i / 3 + 1)
              contr.executeUserAction(EightPuzzleBoard.UP);
          }
        }
      }
    }
View Full Code Here

Examples of aima.core.util.datastructure.XYLocation

*/
public class XYLocationTest {

  @Test
  public void testXYLocationAtributeSettingOnConstruction() {
    XYLocation loc = new XYLocation(3, 4);
    Assert.assertEquals(3, loc.getXCoOrdinate());
    Assert.assertEquals(4, loc.getYCoOrdinate());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.