Ejemplo n.º 1
0
    private int SearchForAll(int level, int id1, int id2) {
      Board board = boards[level];
      Board newBoard = boards[level - 1];
      int res = Integer.MIN_VALUE;
      Point AbleForGo[] = new Point[4 * size];
      int cntAbleForGo = board.getAbleForGo(id1, AbleForGo);
      int cntOldForID1 = board.getCount(id1);

      for (int i = 0; i < cntAbleForGo; ++i) {
        Point newPos = AbleForGo[i];
        newBoard.setAs(board);
        newBoard.go(id1, newPos);
        int cntNewForID1 = newBoard.getCount(id1);
        int newRes = cntNewForID1 - cntOldForID1;
        if (level > 1) newRes -= this.SearchForAll(level - 1, id2, id1);
        if (newRes > res) res = newRes;
      }

      return res;
    }
Ejemplo n.º 2
0
    public void run() {
      Board board = boards[level];
      Board newBoard = boards[level - 1];
      int res = Integer.MIN_VALUE;
      // Point AbleForGo[]=new Point[4*size];
      // int cntAbleForGo=board.getAbleForGo(id1, AbleForGo);
      int cntOldForID1 = board.getCount(id1);

      // for(int i=0;i<cntAbleForGo;++i)
      {
        Point newPos = goFirst;
        newBoard.setAs(board);
        newBoard.go(id1, newPos);
        int cntNewForID1 = newBoard.getCount(id1);
        int newRes = cntNewForID1 - cntOldForID1;
        if (level > 1) newRes -= this.SearchForAll(level - 1, id2, id1);
        if (newRes > res) res = newRes;
      }

      ResM[goFirst.x][goFirst.y] = res;
    }
Ejemplo n.º 3
0
 public void go(int id, int x, int y) {
   go(id, new Point(x, y));
 }