Ejemplo n.º 1
0
  public int MaxMin(StringBuffer board, int turns) {

    StringBuffer info = new StringBuffer("Enter into MaxMin " + board + " turns is " + turns);
    String result = null;
    if (turns == 0) {
      int maxmin = StaticEstimation.StaticEstimationForOpeining(board);

      return maxmin;
    }
    ArrayList<StringBuffer> boardlist = MoveGenerator.GenerateMoveOpening(board, 'W');

    Iterator<StringBuffer> itr = boardlist.iterator();
    turns--;
    int v = -10000;
    while (itr.hasNext()) {

      StringBuffer child_board = itr.next();
      // System.out.println("Calcualte for the "+ child_board +
      // " length is " + boardlist.size());

      int minmax = MinMax(child_board, turns);
      if (minmax > v) {
        v = minmax;
        result = new String(child_board);
      }
    }

    info.append("result is " + result);
    System.out.println(info);
    MinMaxOpening.result = new String(result);
    return v;
  }
Ejemplo n.º 2
0
  public int MinMax(StringBuffer board, int turns) {
    // TODO Auto-generated method stub
    StringBuffer info = new StringBuffer("Enter into MaxMin " + board + " turns is " + turns);
    String result = null;

    if (turns == 0) {
      int minmax = StaticEstimation.StaticEstimationForOpeining(board);

      return minmax;
    }

    ArrayList<StringBuffer> boardlist = MoveGenerator.GenerateMoveOpening(board, 'B');

    Iterator<StringBuffer> itr = boardlist.iterator();
    turns--;
    int v = 10000;
    while (itr.hasNext()) {

      StringBuffer child_board = itr.next();

      int minmax = MaxMin(child_board, turns);
      if (minmax < v) {
        v = minmax;
        result = new String(child_board);
      }
    }

    info.append("result is " + result);
    System.out.println(info);
    return v;
  }