-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCommon.h
40 lines (30 loc) · 831 Bytes
/
Common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
* File: Common.h
* Author: pj
*
* Created on January 16, 2013, 3:53 PM
*/
#ifndef COMMON_H
#define COMMON_H
#include <iostream>
#include <sstream>
#include <string>
#include <assert.h>
using namespace std;
#define DEBUG
#include "Types.h"
#include "Constants.h"
#include "Board.h"
#include "Move.h"
U32 inline bit_scan_forward(U64 bb) { return __builtin_ffsll(bb)-1; }
U64 inline circular_left_shift(U64 target, int shift){
#ifdef DEBUG
assert(shift >= 0);
assert(shift <= 64);
#endif
return (target << shift) | (target >> (64-shift));
}
bool inline is_valid_piece(U8 piece){ return (piece >= WHITE_PAWN) && (piece <= BLACK_KING); }
bool inline is_valid_square(int square){ return (square >= 0) && (square <= 64); }
bool is_valid_move(U32 move, const class Board &board);
#endif /* COMMON_H */