First commit
[arrocco.git] / pieces.c
blob286a51cfda26ed7fc881b987fa47480499dd8060
1 /* pieces.c
2 28 Feb 2007 */
4 #include <stdbool.h>
6 const int EMPTY = 0, PAWN = 2, KNIGHT = 4, BISHOP = 6,
7 ROOK = 8, QUEEN = 10, KING = 12;
9 const int pieceValues[14] = {0, 0, 10, -10, 30, -30, 30, -30, 50, -50, 90, -90,
10 8888, -8888};
12 #define WHITE(x) (x)
13 #define BLACK(x) (x+1)
15 inline bool isWhite(int x){
16 return x && ((~x) & 1);
19 inline bool isBlack(int x){
20 return x & 1;
24 inline int opponent(int x){
25 return x ^ 1;
28 int promoteTo(int pawn, int piece){
29 return (pawn & 1) | piece;
32 bool sameColor(int x, int y){
33 if (x == 0 || y == 0){
34 return false;
35 } else {
36 return !((x ^ y) & 1);
40 bool sameColorNotZero(int x, int y){
41 return !((x ^ y) & 1);