コード例 #1
0
ファイル: GameScenario.java プロジェクト: pliskowski/cecj
 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
ファイル: GameScenario.java プロジェクト: pliskowski/cecj
 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();
 }