Exemple #1
0
 private static BitBoard makeWithoutFileH() {
   BitBoard result = new BitBoard();
   for (BoardSquare s : BoardSquare.values()) {
     if (s.file() != 'h') {
       result.set(s);
     }
   }
   return result;
 }
Exemple #2
0
 private static BitBoard makeInteriorSquares() {
   BitBoard result = new BitBoard();
   for (BoardSquare bs : BoardSquare.values()) {
     if (!bs.onEdge()) {
       result.set(bs);
     }
   }
   return result;
 }
Exemple #3
0
 public static BitBoard makeKnightMoves(BoardSquare kn) {
   BitBoard result = new BitBoard();
   for (BoardSquare bs : BoardSquare.values()) {
     if (kn.hasKnightMoveTo(bs)) {
       result.set(bs);
     }
   }
   return result;
 }
Exemple #4
0
 public static BitBoard makeBishopMoves(BoardSquare bish) {
   BitBoard result = new BitBoard();
   for (BoardSquare bs : BoardSquare.values()) {
     if (bish.hasBishopMoveTo(bs)) {
       result.set(bs);
     }
   }
   return result;
 }
Exemple #5
0
 public static BitBoard makeRookMoves(BoardSquare rook) {
   BitBoard result = new BitBoard();
   for (BoardSquare bs : BoardSquare.values()) {
     if (rook.hasRookMoveTo(bs)) {
       result.set(bs);
     }
   }
   return result;
 }
Exemple #6
0
 public BitBoard(String rep) {
   this();
   int displayIndex = 0;
   for (int i = 0; i < rep.length(); ++i) {
     if (rep.charAt(i) != '\n') {
       if (rep.charAt(i) == '1') {
         set(BoardSquare.values()[displayIndex]);
       }
       displayIndex += 1;
     }
   }
 }
Exemple #7
0
 public String toString() {
   StringBuilder sb = new StringBuilder();
   int nextRow = 8;
   for (BoardSquare bs : BoardSquare.values()) {
     sb.append(isSet(bs) ? '1' : '0');
     nextRow -= 1;
     if (nextRow == 0) {
       sb.append('\n');
       nextRow = 8;
     }
   }
   return sb.toString();
 }
Exemple #8
0
 public void clear(BoardSquare bs) {
   bits &= ~bs.getMask();
 }
Exemple #9
0
 public void set(BoardSquare bs) {
   bits |= bs.getMask();
 }
Exemple #10
0
 public boolean isSet(BoardSquare s) {
   return (bits & s.getMask()) != 0;
 }
Exemple #11
0
 @Override
 public BoardSquare next() {
   prev = unseen & -unseen;
   unseen -= prev;
   return BoardSquare.values()[Long.numberOfTrailingZeros(prev)];
 }