Beispiel #1
0
  protected boolean doDefaultApplicationRaw(BoardState destBoardState) {
    BoardState origBoardState = destBoardState.getSingleParentState();
    boolean changed = false;
    Point temprSize;
    Point temprLocation;
    ArrayList<Object> extraData = origBoardState.getExtraData();
    Region curRegion;

    if (origBoardState != null && destBoardState.getParents().size() == 1) {
      int regioncount = ((Integer) origBoardState.getExtraData().get(1)).intValue();
      for (int r = 0; r < regioncount; r++) {
        curRegion = ((Region[]) extraData.get(0))[r];
        if (curRegion.getValue() == 5) {
          Point size = getRegionDimension(destBoardState, r);
          Point location = getRegionLocation(destBoardState, r);
          if (size.x == 2 && size.y == 2) {
            if (origBoardState.getCellContents(location.x, location.y) == Heyawake.CELL_UNKNOWN) {
              changed = true;
              destBoardState.setCellContents(location.x, location.y, Heyawake.CELL_BLACK);
              destBoardState.setCellContents(location.x + 2, location.y, Heyawake.CELL_BLACK);
              destBoardState.setCellContents(location.x + 1, location.y + 1, Heyawake.CELL_BLACK);
              destBoardState.setCellContents(location.x, location.y + 2, Heyawake.CELL_BLACK);
              destBoardState.setCellContents(location.x + 2, location.y + 2, Heyawake.CELL_BLACK);
            }
          }
        }
      }
    }

    String error = checkRuleRaw(destBoardState);
    if (error != null) {
      System.out.println(error + " " + changed);
      changed = false;
      // valid change
    }
    if (!changed) {
      destBoardState = origBoardState.copy();
    }

    return changed;
  }