lots
[arrocco.git] / pieces.c
blob15a266c7033448b178143faf6f9719de112ed26e
1 /* pieces.c
2 28 Feb 2007 */
4 /*
5 This file is part of Arrocco, which is Copyright 2007 Thomas Plick
6 (tomplick 'at' gmail.com).
8 Arrocco is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 Arrocco is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include <stdbool.h>
24 const int EMPTY = 0, PAWN = 2, KNIGHT = 4, BISHOP = 6,
25 ROOK = 8, QUEEN = 10, KING = 12;
27 const int pieceValues[14] = {0, 0, 10, -10, 30, -30, 30, -30, 50, -50, 90, -90,
28 8888, -8888};
30 #define WHITE(x) (x)
31 #define BLACK(x) (x+1)
33 inline bool isWhite(int x){
34 return x && ((~x) & 1);
37 inline bool isBlack(int x){
38 return x & 1;
42 inline int opponent(int x){
43 return x ^ 1;
46 int promoteTo(int pawn, int piece){
47 return (pawn & 1) | piece;
50 bool sameColor(int x, int y){
51 if (x == 0 || y == 0){
52 return false;
53 } else {
54 return !((x ^ y) & 1);
58 bool sameColorNotZero(int x, int y){
59 return !((x ^ y) & 1);