@Override
 protected int getYFromSq(int sq) {
   if (sq >= 0) {
     return Position.getY(sq);
   } else {
     int p = -2 - sq;
     if (landScape) {
       switch (p) {
         case Piece.WKING:
         case Piece.BKING:
           return 0;
         case Piece.WQUEEN:
         case Piece.BQUEEN:
           return 1;
         case Piece.WROOK:
         case Piece.BROOK:
           return 2;
         case Piece.WBISHOP:
         case Piece.BBISHOP:
           return 3;
         case Piece.WKNIGHT:
         case Piece.BKNIGHT:
           return 4;
         case Piece.WPAWN:
         case Piece.BPAWN:
           return 5;
         default:
           return 6;
       }
     } else {
       return Piece.isWhite(p) ? -1 : -2;
     }
   }
 }
 /** Compute material difference for a position. */
 public static MaterialDiff getMaterialDiff(Position pos) {
   StringBuilder whiteString = new StringBuilder();
   StringBuilder blackString = new StringBuilder();
   for (int p = Piece.WPAWN; p >= Piece.WKING; p--) {
     int diff = pos.nPieces(p) - pos.nPieces(Piece.swapColor(p));
     while (diff < 0) {
       whiteString.append(Piece.toUniCode(Piece.swapColor(p)));
       diff++;
     }
     while (diff > 0) {
       blackString.append(Piece.toUniCode(p));
       diff--;
     }
   }
   return new MaterialDiff(whiteString, blackString);
 }