예제 #1
0
 private Piece getWorstPiece(boolean hurt_player) {
   Brain.Move wMove = null;
   Brain.Move tMove;
   int index = 0;
   for (int i = 0; i < pieces.length; i++) {
     tMove = mBrain.bestMove(board, pieces[i], board.getHeight() - TOP_SPACE, null);
     if (i == 0) wMove = tMove;
     if (tMove == null) { // this piece loses the game now
       return pieces[i];
     }
     if ((hurt_player && tMove.score >= wMove.score)
         || (!hurt_player && tMove.score <= wMove.score)) {
       wMove = tMove;
       index = i;
     }
   }
   return pieces[index];
 }
예제 #2
0
  public void tick(int verb) {
    if (brainPlay.isSelected()) {
      board.undo();
      if (verb == DOWN) {
        if (cur_count != super.count) {
          mMove = mBrain.bestMove(board, currentPiece, board.getHeight() - TOP_SPACE, mMove);
          cur_count = super.count;
        }
        if (mMove == null || mMove.piece == null || currentPiece == null) {
          stopGame();
          return; // game over
        }
        if (!currentPiece.equals(mMove.piece)) super.tick(ROTATE);

        if (currentX < mMove.x) super.tick(RIGHT);
        if (currentX > mMove.x) super.tick(LEFT);
      }
    }
    super.tick(verb);
  }