Examples of Coord


Examples of mines.MinefieldContainer.Coord

      int row = i * 2;

      // down
      for (int j = 0; j < columns; j++) {

        Coord coord = new Coord(row, j);
        result.add(coord);
      }

      // up
      for (int j = 0; j < columns - 1; j++) {

        Coord coord = new Coord(row + 1, j);
        result.add(coord);
      }
    }
   
    return result;
View Full Code Here

Examples of mines.MinefieldContainer.Coord

    for(int i = 0; i < mines; i++) {
      // take a random number from interval <0; count of covered fields - 1>
      // and lay a mine according to it

      int fieldOrder = (Math.abs(random.nextInt()) % coveredFields.size());
      Coord minedCoord = coveredFields.get(fieldOrder);

      assert(minefield.get(minedCoord).equals(GUI_FIELD.COVERED));
      minefield.set(minedCoord, GUI_FIELD.MINE);

      // removed the mined field
View Full Code Here

Examples of mines.MinefieldContainer.Coord

    areaSearchStack.push(coveredField);

    while(!areaSearchStack.isEmpty()) {
      // remove taken field from stack and add it to the set to prevent
      // the duplicities
      Coord areaField = areaSearchStack.pop();
      affectedFieldsSet.add(areaField);

      List<Coord> aroundFields = minefield.getAroundFields(areaField, AROUND_FIELDS_DISTANCE.TWO,
          SOLVER_FIELD.NON_ZERO_NUMBER_FLAG, CENTER_OPTION.EXCLUDE_CENTER);
View Full Code Here

Examples of mines.MinefieldContainer.Coord

      mAborted = false;
      throw new ComputationAbortedException();
    }

    // take the first non zero field
    Coord nextNonzeroField = null;
    for (Coord affected : affectedFields) {

      SOLVER_FIELD fieldValue = mContent.get(affected);
      if(fieldValue.isFiltered(SOLVER_FIELD.NON_ZERO_NUMBER_FLAG)) {
        nextNonzeroField = affected;
View Full Code Here

Examples of mines.MinefieldContainer.Coord

    // we will pick up the mines one by one in the reverse order and
    // test the minefield inconsistency each time
    for(int i = 0; i < minesCount; i++) {
      int lastIndex = (minesCount - 1) - i;
      Coord minedCoord = minedFields.get(lastIndex);

      pickUpMine(minedCoord);
      pickedUpMines++;

      if(checkOneField(affectedField)) {
        // the minefield has a chance to be consistent now
        // we will store the number of picked up mines
        backjumpLength = pickedUpMines - 1;
        break;
      }
    }

    // now we have to put the removed mines back
    for(int i = 0; i < pickedUpMines; i++)
    {
      int lastIndex = (minesCount - 1) - i;
      Coord minedCoord = minedFields.get(lastIndex);

      if(!canPutMine(minedCoord)) {
        throw new MinesSolverInternalError("Unable to put back removed mines.");
      }
View Full Code Here

Examples of org.fusesource.jansi.internal.Kernel32.COORD

  protected void processEraseScreen(int eraseOption) throws IOException {
    getConsoleInfo();
    int[] written = new int[1];
    switch(eraseOption) {
    case ERASE_SCREEN:
      COORD topLeft = new COORD();
      topLeft.x = 0;
      topLeft.y = info.window.top;
      int screenLength = info.window.height() * info.size.x;
      FillConsoleOutputCharacterW(console, ' ', screenLength, topLeft, written);
      break;
    case ERASE_SCREEN_TO_BEGINING:
      COORD topLeft2 = new COORD();
      topLeft2.x = 0;
      topLeft2.y = info.window.top;
      int lengthToCursor = (info.cursorPosition.y - info.window.top) * info.size.x
        + info.cursorPosition.x;
      FillConsoleOutputCharacterW(console, ' ', lengthToCursor, topLeft2, written);
View Full Code Here

Examples of org.fusesource.jansi.internal.Kernel32.COORD

  protected void processEraseLine(int eraseOption) throws IOException {
    getConsoleInfo();
    int[] written = new int[1];
    switch(eraseOption) {
    case ERASE_LINE:
      COORD leftColCurrRow = info.cursorPosition.copy();
      leftColCurrRow.x = 0;
      FillConsoleOutputCharacterW(console, ' ', info.size.x, leftColCurrRow, written);
      break;
    case ERASE_LINE_TO_BEGINING:
      COORD leftColCurrRow2 = info.cursorPosition.copy();
      leftColCurrRow2.x = 0;
      FillConsoleOutputCharacterW(console, ' ', info.cursorPosition.x, leftColCurrRow2, written);
      break;
    case ERASE_LINE_TO_END:
      int lengthToLastCol = info.size.x - info.cursorPosition.x;
View Full Code Here

Examples of pair.gameoflife.a20140102.CoordTest.Coord

    @Test
    public void shouldSumSelfNeighbourCountAndNextNeighbourCount() {
        final int selfNeighbourCount = 2;
        final int nextNeighbourCount = 40;

        Coord selfCoord = new Coord(0, 0) {
            @Override
            public int oneForNeighbour(Coord other) {
                return selfNeighbourCount;
            }
        };
View Full Code Here

Examples of pair.gameoflife.a20140102.CoordTest.Coord

    @Test
    public void shouldNotCountTooFarNeighbourLeftOrUpAsAnyNeighbours() {
        assertThat(coords()
                .with(0, 2)
                .with(2, 0)
           .countNeighbours(new Coord(2, 2)), is(0));
    }
View Full Code Here

Examples of pair.gameoflife.a20140102.CoordTest.Coord

           .countNeighbours(new Coord(2, 2)), is(0));
    }

    @Test
    public void shouldCountSelfAsNeighbours() {
        assertThat(coords().with(2, 2).countNeighbours(new Coord(2, 2)), is(1));
    }
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.