The Pedigree Project  0.1
SideState.h
1 /*
2  *
3  * Copyright (c) 2008-2014, Pedigree Developers
4  *
5  * Please see the CONTRIB file in the root of the source tree for a full
6  * list of contributors.
7  *
8  * Permission to use, copy, modify, and distribute this software for any
9  * purpose with or without fee is hereby granted, provided that the above
10  * copyright notice and this permission notice appear in all copies.
11  *
12  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19  */
20 
21 #ifndef SIDESTATE_H
22 #define SIDESTATE_H
23 
24 #include "Bitboard.h"
25 #include "Move.h"
26 #include "Square.h"
27 
28 enum Piece
29 {
30  Pawn,
31  Knight,
32  Rook,
33  Bishop,
34  Queen,
35  King
36 };
37 
44 class SideState
45 {
46 public:
50  SideState();
51 
52  ~SideState() {}
53 
57  void friendlyMove(Move m, Piece promotion=Pawn);
58  void enemyMove(Move m, Bitboard enemyPawns);
59 
63  bool isLegal(Move m, Bitboard enemyPieces, Bitboard enemyPawnsEnPassant);
64 
68  bool isCastle(Move m);
69 
73  bool isAttacking(Square sq, Bitboard enemyPieces); // Is (col,row) under attack by us?
74  // TODO add en passant.
75 
76  long heuristic();
77 
81  Square firstPawn();
82  Square firstRook();
83  Square firstKnight();
84  Square firstBishop();
85  Square firstQueen();
86  Square firstKing();
87 
88  Square next();
89 
93  bool rooksMoved[2];
94  bool kingMoved;
95  bool hasCastled;
96 
101  Bitboard rooks;
102  Bitboard bishops;
103  Bitboard knights;
104  Bitboard queen;
105  Bitboard king;
106  Bitboard enPassant; // a bitboard giving squares which, if attacked, would result in a pawn being
107  // taken.
108 
113 
118  int nextPiece;
119 
120 };
121 
122 #endif
Bitboard pawns
Definition: SideState.h:100
Bitboard attack
Definition: SideState.h:112
void friendlyMove(Move m, Piece promotion=Pawn)
Definition: SideState.cc:239
bool rooksMoved[2]
Definition: SideState.h:93
bool isCastle(Move m)
Definition: SideState.cc:187
Bitboard nextBoard
Definition: SideState.h:117
Definition: Move.h:29
bool isAttacking(Square sq, Bitboard enemyPieces)
Definition: SideState.cc:139
Square firstPawn()
Definition: SideState.cc:92
bool isLegal(Move m, Bitboard enemyPieces, Bitboard enemyPawnsEnPassant)
Definition: SideState.cc:194
Definition: Square.h:24