Package minesweeper.ai.utils

Examples of minesweeper.ai.utils.Node


      for(List<Position> positions : helper.getClosedUnknownBorderCells()) {
        probBacktrackValid = false;
        toPickMap.clear(); toFlagMap.clear(); solutionsFound = 0;
        toPick.clear(); toPick.addAll(positions);
        toFlag.clear(); toFlag.addAll(positions);
        backtrackSolve(grid, helper, positions, new Node(null,null), new Node(null,null));
        if(toPick.size() == 0 && toFlag.size() == 0) {
          toPick.clear(); toFlag.clear();
          Entry<Position, Integer> pickMax = null, flagMax = null;
          if(toPickMap.size() >= 1) pickMax = Collections.max(toPickMap.entrySet(), (a,b) -> a.getValue()-b.getValue());
          if(toFlagMap.size() >= 1) flagMax = Collections.max(toFlagMap.entrySet(), (a,b) -> a.getValue()-b.getValue());
View Full Code Here


    }
    Position p = positions.remove(0);
    board.setCell(p,Cell.NO_BOMB);
    boolean result = false;
    if(helper.validate(p))
      if(backtrackSolve(board,helper,positions,new Node(p,outPick),outFlag))
        result = true;
    board.setCell(p, Cell.FLAG);
    if(helper.validate(p))
      if(backtrackSolve(board,helper,positions,outPick,new Node(p,outFlag)))
        result = true;
    board.setCell(p, Cell.UNKNOWN);
    positions.add(0,p);
    return result;
  }
View Full Code Here

        List<Position> unknown = helper.getCellsByValue(Cell.UNKNOWN);
        int bombsToPlace = board.getRemainingBombs();
        toFlag.clear(); toPick.clear();
        if(Combinations.nCr(unknown.size(), bombsToPlace) < SEARCH_SPACE_LIMIT) {
          toFlag.addAll(unknown); toPick.addAll(unknown);
          enumerateBombLocations(helper, unknown, new Node(null,null), new Node(null,null), bombsToPlace);
          dt = DeductionType.BRUTE_FORCE;
          if(debug == DebugMode.ON) System.out.println("BRUTE FORCE results: " + toPick + toFlag);
          return toPick.size() > 0 || toFlag.size() > 0;
        } else return false;
    }
View Full Code Here

            }
          }
            return;
        } else if(bombsToPlace < 0 || bombsToPlace > unknown.size()) return;
        Position p = unknown.remove(0);
        enumerateBombLocations(helper,new ArrayList<>(unknown),new Node(p,flagLocs), pickLocs, bombsToPlace-1);
        enumerateBombLocations(helper,new ArrayList<>(unknown),flagLocs, new Node(p,pickLocs), bombsToPlace);
    }
View Full Code Here

        List<Position> unknown = helper.getCellsByValue(Cell.UNKNOWN);
        int bombsToPlace = board.getRemainingBombs();
        toFlag.clear(); toPick.clear();
        if(Combinations.nCr(unknown.size(), bombsToPlace) < SEARCH_SPACE_LIMIT) {
          toFlag.addAll(unknown); toPick.addAll(unknown);
          enumerateBombLocations(helper, board, unknown, new Node(null,null), new Node(null,null), bombsToPlace);
          return toPick.size() > 0 || toFlag.size() > 0;
        } else return false;

    }
View Full Code Here

            }
          }
            return;
        } else if(bombsToPlace < 0 || bombsToPlace > unknown.size()) return;
        Position p = unknown.remove(0);
        enumerateBombLocations(helper,board,new ArrayList<>(unknown),new Node(p,flagLocs), pickLocs, bombsToPlace-1);
        enumerateBombLocations(helper,board,new ArrayList<>(unknown),flagLocs, new Node(p,pickLocs), bombsToPlace);
    }
View Full Code Here

      for(List<Position> positions : helper.getClosedUnknownBorderCells()) {
//        if(positions.size() > 15)
//          positions = positions.subList(0, 15);
        toPick.clear(); toPick.addAll(positions);
        toFlag.clear(); toPick.addAll(positions);
        backtrackSolve(grid, helper, positions, new Node(null,null), new Node(null,null));
        dt = DeductionType.BACKTRACK;
        if(toPick.size() > 0 || toFlag.size() > 0)
          return true;
      }
      return false;
View Full Code Here

    }
    Position p = positions.remove(0);
    board.setCell(p,Cell.NO_BOMB);
    boolean result = false;
    if(helper.validate(p))
      if(backtrackSolve(board,helper,positions,new Node(p,outPick),outFlag))
        result = true;
    board.setCell(p, Cell.FLAG);
    if(helper.validate(p))
      if(backtrackSolve(board,helper,positions,outPick,new Node(p,outFlag)))
        result = true;
    board.setCell(p, Cell.UNKNOWN);
    positions.add(0,p);
    return result;
  }
View Full Code Here

        List<Position> unknown = helper.getCellsByValue(Cell.UNKNOWN);
        int bombsToPlace = board.getRemainingBombs();
        toFlag.clear(); toPick.clear();
        if(Combinations.nCr(unknown.size(), bombsToPlace) < SEARCH_SPACE_LIMIT) {
          toFlag.addAll(unknown); toPick.addAll(unknown);
          enumerateBombLocations(helper, unknown, new Node(null,null), new Node(null,null), bombsToPlace);
          dt = DeductionType.BRUTE_FORCE;
          return toPick.size() > 0 || toFlag.size() > 0;
        } else return false;

    }
View Full Code Here

            }
          }
            return;
        } else if(bombsToPlace < 0 || bombsToPlace > unknown.size()) return;
        Position p = unknown.remove(0);
        enumerateBombLocations(helper,new ArrayList<>(unknown),new Node(p,flagLocs), pickLocs, bombsToPlace-1);
        enumerateBombLocations(helper,new ArrayList<>(unknown),flagLocs, new Node(p,pickLocs), bombsToPlace);
    }
View Full Code Here

TOP

Related Classes of minesweeper.ai.utils.Node

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.