예제 #1
0
 private static BitBoard makeWithoutFileH() {
   BitBoard result = new BitBoard();
   for (BoardSquare s : BoardSquare.values()) {
     if (s.file() != 'h') {
       result.set(s);
     }
   }
   return result;
 }
예제 #2
0
 private static BitBoard makeInteriorSquares() {
   BitBoard result = new BitBoard();
   for (BoardSquare bs : BoardSquare.values()) {
     if (!bs.onEdge()) {
       result.set(bs);
     }
   }
   return result;
 }
예제 #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;
 }
예제 #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;
 }
예제 #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;
 }
예제 #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;
     }
   }
 }
예제 #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();
 }
예제 #8
0
 public void clear(BoardSquare bs) {
   bits &= ~bs.getMask();
 }
예제 #9
0
 public void set(BoardSquare bs) {
   bits |= bs.getMask();
 }
예제 #10
0
 public boolean isSet(BoardSquare s) {
   return (bits & s.getMask()) != 0;
 }
예제 #11
0
 @Override
 public BoardSquare next() {
   prev = unseen & -unseen;
   unseen -= prev;
   return BoardSquare.values()[Long.numberOfTrailingZeros(prev)];
 }