Beispiel #1
0
 public ArrayList<Piece> getListByColor(Color color) {
   ArrayList<Piece> piecesList = new ArrayList<Piece>();
   for (Piece piece : row) {
     if (piece.getColor() == color) piecesList.add(piece);
   }
   return piecesList;
 }
Beispiel #2
0
 private String shortName(Piece p) {
   if (p == null) {
     return "";
   }
   String ret = "" + p.getColor().toString().charAt(0);
   Type t = p.getType();
   switch (t) {
     case PAWN:
       ret += "P";
       break;
     case ROOK:
       ret += "R";
       break;
     case KNIGHT:
       ret += "N";
       break;
     case BISHOP:
       ret += "B";
       break;
     case QUEEN:
       ret += "Q";
       break;
     case KING:
       ret += "K";
       break;
   }
   return ret;
 }
Beispiel #3
0
 public double getScoreFromRow(Color color) {
   double score = 0;
   for (Piece piece : row) {
     if (piece.getColor() == color) {
       score += piece.getScore();
     }
   }
   return score;
 }