예제 #1
0
 public static double getValue(BoardGame game, Player player) {
   if (game.endOfGame()) {
     int result;
     if (game.getOutcome() > 0) {
       result = 1;
     } else if (game.getOutcome() < 0) {
       result = -1;
     } else {
       result = 0;
     }
     return result;
   } else {
     return Math.tanh(player.evaluate(game.getBoard()));
   }
 }
예제 #2
0
 public int play(BoardGame game) {
   while (!game.endOfGame()) {
     List<? extends GameMove> moves = game.findMoves();
     if (!moves.isEmpty()) {
       GameMove bestMove = null;
       if (Math.random() < prob[game.getCurrentPlayer()]) {
         bestMove = moves.get((int) (Math.random() * moves.size()));
       } else {
         bestMove = chooseBestMove(game, players[game.getCurrentPlayer()], moves);
       }
       game.makeMove(bestMove);
     } else {
       game.pass();
     }
   }
   return game.getOutcome();
 }