-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbitboard.h
101 lines (68 loc) · 1.64 KB
/
bitboard.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
File: bitboard.h
Created: November 21, 1999
Modified: November 24, 2005
Author: Gunnar Andersson ([email protected])
Toshihiko Okuhara
Contents:
*/
#ifndef BITBOARD_H
#define BITBOARD_H
#include "macros.h"
#define APPLY_NOT( a ) { \
a.high = ~a.high; \
a.low = ~a.low; \
}
#define APPLY_XOR( a, b ) { \
a.high ^= b.high; \
a.low ^= b.low; \
}
#define APPLY_OR( a, b ) { \
a.high |= b.high; \
a.low |= b.low; \
}
#define APPLY_AND( a, b ) { \
a.high &= b.high; \
a.low &= b.low; \
}
#define APPLY_ANDNOT( a, b ) { \
a.high &= ~b.high; \
a.low &= ~b.low; \
}
#define FULL_XOR( a, b, c ) { \
a.high = b.high ^ c.high; \
a.low = b.low ^ c.low; \
}
#define FULL_OR( a, b, c ) { \
a.high = b.high | c.high; \
a.low = b.low | c.low; \
}
#define FULL_AND( a, b, c ) { \
a.high = b.high & c.high; \
a.low = b.low & c.low; \
}
#define FULL_ANDNOT( a, b, c ) { \
a.high = b.high & ~c.high; \
a.low = b.low & ~c.low; \
}
#define CLEAR( a ) { \
a.high = 0; \
a.low = 0; \
}
typedef struct {
unsigned int high;
unsigned int low;
} BitBoard;
extern BitBoard square_mask[100];
unsigned int REGPARM(2)
non_iterative_popcount( unsigned int n1, unsigned int n2 );
unsigned int REGPARM(2)
iterative_popcount( unsigned int n1, unsigned int n2 );
unsigned int REGPARM(1)
bit_reverse_32( unsigned int val );
void
set_bitboards( int *board, int side_to_move,
BitBoard *my_out, BitBoard *opp_out );
void
init_bitboard( void );
#endif /* BITBOARD_H */