]> git.sesse.net Git - stockfish/blobdiff - src/position.cpp
Update copyright info
[stockfish] / src / position.cpp
index e32f8f4973cf4e06f913067baae7e4f38d014318..ff93e532d999c3012e4774a35ea98a1e07c4417b 100644 (file)
@@ -1,13 +1,14 @@
 /*
-  Glaurung, a UCI chess playing engine.
-  Copyright (C) 2004-2008 Tord Romstad
+  Stockfish, a UCI chess playing engine derived from Glaurung 2.1
+  Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
+  Copyright (C) 2008 Marco Costalba
 
-  Glaurung is free software: you can redistribute it and/or modify
+  Stockfish is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.
 
-  Glaurung is distributed in the hope that it will be useful,
+  Stockfish is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
@@ -385,8 +386,8 @@ bool Position::square_is_attacked(Square s, Color c) const {
 
 Bitboard Position::attacks_to(Square s) const {
   return
-    (black_pawn_attacks(s) & pawns(WHITE)) |
-    (white_pawn_attacks(s) & pawns(BLACK)) |
+    (pawn_attacks(BLACK, s) & pawns(WHITE)) |
+    (pawn_attacks(WHITE, s) & pawns(BLACK)) |
     (piece_attacks<KNIGHT>(s) & pieces_of_type(KNIGHT)) |
     (piece_attacks<ROOK>(s) & rooks_and_queens()) |
     (piece_attacks<BISHOP>(s) & bishops_and_queens()) |
@@ -406,13 +407,13 @@ bool Position::piece_attacks_square(Square f, Square t) const {
   assert(square_is_ok(t));
 
   switch(piece_on(f)) {
-  case WP: return white_pawn_attacks_square(f, t);
-  case BP: return black_pawn_attacks_square(f, t);
-  case WN: case BN: return knight_attacks_square(f, t);
-  case WB: case BB: return bishop_attacks_square(f, t);
-  case WR: case BR: return rook_attacks_square(f, t);
-  case WQ: case BQ: return queen_attacks_square(f, t);
-  case WK: case BK: return king_attacks_square(f, t);
+  case WP: return pawn_attacks_square(WHITE, f, t);
+  case BP: return pawn_attacks_square(BLACK, f, t);
+  case WN: case BN: return piece_attacks_square<KNIGHT>(f, t);
+  case WB: case BB: return piece_attacks_square<BISHOP>(f, t);
+  case WR: case BR: return piece_attacks_square<ROOK>(f, t);
+  case WQ: case BQ: return piece_attacks_square<QUEEN>(f, t);
+  case WK: case BK: return piece_attacks_square<KING>(f, t);
   default: return false;
   }
 
@@ -549,7 +550,7 @@ bool Position::move_is_check(Move m, Bitboard dcCandidates) const {
 
       switch(move_promotion(m)) {
       case KNIGHT:
-        return knight_attacks_square(to, ksq);
+        return piece_attacks_square<KNIGHT>(to, ksq);
       case BISHOP:
         return bit_is_set(bishop_attacks_bb(to, b), ksq);
       case ROOK:
@@ -668,13 +669,13 @@ bool Position::move_attacks_square(Move m, Square s) const {
   assert(square_is_occupied(f));
 
   switch(piece_on(f)) {
-  case WP: return white_pawn_attacks_square(t, s);
-  case BP: return black_pawn_attacks_square(t, s);
-  case WN: case BN: return knight_attacks_square(t, s);
-  case WB: case BB: return bishop_attacks_square(t, s);
-  case WR: case BR: return rook_attacks_square(t, s);
-  case WQ: case BQ: return queen_attacks_square(t, s);
-  case WK: case BK: return king_attacks_square(t, s);
+  case WP: return pawn_attacks_square(WHITE, t, s);
+  case BP: return pawn_attacks_square(BLACK, t, s);
+  case WN: case BN: return piece_attacks_square<KNIGHT>(t, s);
+  case WB: case BB: return piece_attacks_square<BISHOP>(t, s);
+  case WR: case BR: return piece_attacks_square<ROOK>(t, s);
+  case WQ: case BQ: return piece_attacks_square<QUEEN>(t, s);
+  case WK: case BK: return piece_attacks_square<KING>(t, s);
   default: assert(false);
   }
 
@@ -847,9 +848,9 @@ void Position::do_move(Move m, UndoInfo &u, Bitboard dcCandidates) {
     }
     if(piece == PAWN) {
       if(abs(int(to) - int(from)) == 16) {
-        if((us == WHITE && (white_pawn_attacks(from + DELTA_N) &
+        if((us == WHITE && (pawn_attacks(WHITE, from + DELTA_N) &
                             pawns(BLACK))) ||
-           (us == BLACK && (black_pawn_attacks(from + DELTA_S) &
+           (us == BLACK && (pawn_attacks(BLACK, from + DELTA_S) &
                             pawns(WHITE)))) {
           epSquare = Square((int(from) + int(to)) / 2);
           key ^= zobEp[epSquare];
@@ -1632,8 +1633,8 @@ int Position::see(Square from, Square to) const {
     (bishop_attacks_bb(to, occ) & bishops_and_queens()) |
     (piece_attacks<KNIGHT>(to) & knights()) |
     (piece_attacks<KING>(to) & kings()) |
-    (white_pawn_attacks(to) & pawns(BLACK)) |
-    (black_pawn_attacks(to) & pawns(WHITE));
+    (pawn_attacks(WHITE, to) & pawns(BLACK)) |
+    (pawn_attacks(BLACK, to) & pawns(WHITE));
   attackers &= occ;
 
   // If the opponent has no attackers, we are finished: