Beispiel #1
0
 private Collection getMovesOfValue(int target) {
   Collection moves = new HashSet();
   for (Iterator i = itsMoves.iterator(); i.hasNext(); ) {
     AbstractMove move = (AbstractMove) i.next();
     if (move.getScore() == target) moves.add(move);
   }
   return moves;
 }
Beispiel #2
0
 private AbstractMove findHighestScoringMove() {
   AbstractMove bestMove = new IllegalMove();
   for (Iterator i = itsMoves.iterator(); i.hasNext(); ) {
     AbstractMove move = (AbstractMove) i.next();
     if (move.getScore() > bestMove.getScore()) bestMove = move;
   }
   return bestMove;
 }
Beispiel #3
0
 public void search(ChessBoard board, Player player) {
   itsTable = new PositionHashTable();
   itsMoves.clear();
   itsPlayer = player;
   itsBoard = board;
   Collection moves = getAllMoves(player);
   for (Iterator i = moves.iterator(); i.hasNext(); ) {
     AbstractMove move = (AbstractMove) i.next();
     move.getPiece().findMoves_safe();
     move = player.movePiece(move);
     itsBoard.recordPosition();
     String positionCode = itsBoard.getPositionCode() + player.getColor();
     int score = examineMove(move, player, itsSearchQuality, positionCode);
     move.setScore(score);
     itsMoves.add(move);
     itsBoard.removeLastPosition();
     player.reverseMove(move);
   }
 }