Ejemplo n.º 1
0
  @Override
  public Set<Move> getPossibleMoves(State state) {
    ArrayList<Move> temp = new ArrayList<Move>();
    Set<Move> result = new HashSet<Move>();
    temp = possibleMovePosition(state.getTurn(), state);
    if (state.getGameResult() != null) return result;

    for (int i = 0; i < temp.size(); i++) {
      result.add(temp.get(i));
    }

    return result;
  }
Ejemplo n.º 2
0
 @Override
 public Set<Position> getPossibleStartPositions(State state) {
   Color color = state.getTurn();
   Set<Position> result = new HashSet<Position>();
   if (state.getGameResult() != null) return result;
   for (int i = 0; i <= 7; i++) {
     for (int j = 0; j <= 7; j++) {
       Piece piece = state.getPiece(i, j);
       if ((piece != null) && (piece.getColor().equals(color))) {
         PieceKind pk = piece.getKind();
         if (pk.equals(PAWN)) {
           ArrayList<Move> temp = new ArrayList<Move>();
           addPossiPawnMove(color, new Position(i, j), state, temp);
           if (temp.size() > 0) result.add(new Position(i, j));
         }
         if (pk.equals(KNIGHT)) {
           ArrayList<Move> temp = new ArrayList<Move>();
           addPossiKnightMove(color, new Position(i, j), state, temp);
           if (temp.size() > 0) result.add(new Position(i, j));
         }
         if (pk.equals(QUEEN)) {
           ArrayList<Move> temp = new ArrayList<Move>();
           addPossiQueenMove(color, new Position(i, j), state, temp);
           if (temp.size() > 0) result.add(new Position(i, j));
         }
         if (pk.equals(ROOK)) {
           ArrayList<Move> temp = new ArrayList<Move>();
           addPossiRookMove(color, new Position(i, j), state, temp);
           if (temp.size() > 0) result.add(new Position(i, j));
         }
         if (pk.equals(BISHOP)) {
           ArrayList<Move> temp = new ArrayList<Move>();
           addPossiBishopMove(color, new Position(i, j), state, temp);
           if (temp.size() > 0) result.add(new Position(i, j));
         }
         if (pk.equals(KING)) {
           ArrayList<Move> temp = new ArrayList<Move>();
           addPossiKingMove(color, new Position(i, j), state, temp);
           if (temp.size() > 0) result.add(new Position(i, j));
         }
       }
     }
   }
   return result;
 }