home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / ARASAN_S.ZIP / BEARING.H < prev    next >
C/C++ Source or Header  |  1994-08-07  |  3KB  |  69 lines

  1. // Copyright 1992 by Jon Dart.  All Rights Reserved.
  2.  
  3. #ifndef _BEARING_H
  4. #define _BEARING_H
  5. #include "board.h"
  6.  
  7. extern const int Direction[2];
  8.  
  9. extern const byte KnightSquares[64][8];
  10.  
  11. extern const byte KingSquares[64][8];
  12.  
  13. extern const byte BishopSquares[64][32];
  14.  
  15. extern const byte RookSquares[64][32];
  16.  
  17. extern const int RankIncr;    // add this to move 1 rank
  18.  
  19. class Bearing
  20. {
  21.      // Finds pseudo-legal moves for individual pieces, plus
  22.      // related functions.
  23.  
  24.      public:
  25.          
  26.      enum { MaxBearSq = 28 };         
  27.      enum { Offset = 9 };
  28.  
  29.      static unsigned BearSq( const Board &board,
  30.      const Square loc, Square *squares);
  31.      // Returns all squares to which a piece at location 'loc' can move.
  32.      // It does not include castling moves, but does include en passant
  33.      // captures and pawn promotions.  It doesn't check for pins, 
  34.      // and hence may return some illegal moves.
  35.          
  36.      static unsigned Attack( const Board &board,
  37.      const Square loc, const ColorType side,
  38.      Square *squares, Boolean indirect = False);
  39.      // returns a list of all squares on which pieces of color "side"
  40.      // reside which attack the piece at "loc".  The function return
  41.      // value is the number of such pieces.  If "loc" is empty,
  42.      // returns all squares from which pieces can move to "loc".
  43.      // En passant captures are not included.
  44.      // If indirect = True, include "stacked" attackers (sliding pieces
  45.      // behind a piece of the same color).  Each such piece is offset
  46.      // a constant (9) in the square array from the piece it is stacked
  47.      // behind.
  48.  
  49.      static unsigned Attack_or_Defend( const Board &board, const Square &loc,
  50.          Square *squares);
  51.      // returns a list of all squares (empty or not) which the piece
  52.      // at "loc" attacks or defends.  Note that this includes squares
  53.      // to which the piece cannot move (e.g. squares occupied by pieces
  54.      // of its color).  En passant captures are not included.
  55.          
  56.      static Boolean Pinned( const Board &board, const Square loc,
  57.          Piece &PinnedByPiece, 
  58.          Square &PinnedBySquare,
  59.          int &dir);
  60.      // returns TRUE if the piece at location 'square' is pinned. If it
  61.      // is pinned, also returns PinnedByPiece = piece pinning piece at
  62.      // 'square', PinnedBySquare = pinning piece's square, dir =
  63.      // direction of pin.         
  64.      // We could call Attacks to get this information, but this is faster.
  65.          
  66. };
  67.  
  68. #endif
  69.