Package mines.MinefieldContainer

Examples of mines.MinefieldContainer.Coord


    MinefieldContainer<GUI_FIELD> instance = new MinefieldContainer<GUI_FIELD>(1);

    List<Coord> coords = instance.getAroundFields(0, 0);
   
    List<Coord> expectedCoords = new ArrayList<Coord>();
    expectedCoords.add(new Coord(0,0));
   
    TestSuite.assertListsEquals(expectedCoords, coords);
  }
View Full Code Here


    Set<Coord> real = new HashSet<Coord>(coords);

    Assert.assertEquals(coords.size(), real.size());

    Set<Coord> expectedCoords = new HashSet<Coord>();
    expectedCoords.add(new Coord(0,0));
    expectedCoords.add(new Coord(0,1));
    expectedCoords.add(new Coord(1,0));
    expectedCoords.add(new Coord(1,1));
    expectedCoords.add(new Coord(2,0));
    expectedCoords.add(new Coord(2,1));
    expectedCoords.add(new Coord(3,0));
    expectedCoords.add(new Coord(4,0));
   
    TestSuite.assertSetsEquals(expectedCoords, real);
  }
View Full Code Here

      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

    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

    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

      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

    // 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

TOP

Related Classes of mines.MinefieldContainer.Coord

Copyright © 2018 www.massapicom. 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.