My Project
|
#include <stdio.h>
Go to the source code of this file.
Macros | |
#define | DLL_API |
#define | foreach_bit(i, b) for (i = first_bit(b); b; i = next_bit(&b)) |
#define | x_to_bit(x) X_TO_BIT[x] |
Functions | |
DLL_API int | bit_count (unsigned long long) |
Count the number of bits set to one in an unsigned long long. More... | |
int | bit_weighted_count (const unsigned long long) |
count the number of discs, counting the corners twice. More... | |
DLL_API int | first_bit (unsigned long long) |
Search the first bit set. More... | |
int | next_bit (unsigned long long *) |
Search the next bit set. More... | |
DLL_API int | last_bit (unsigned long long) |
Search the last bit set (same as log2()). More... | |
void | bitboard_write (const unsigned long long, FILE *) |
Print an unsigned long long as a board. More... | |
unsigned long long | transpose (unsigned long long) |
Transpose the unsigned long long (symetry % A1-H8 diagonal). More... | |
unsigned long long | vertical_mirror (unsigned long long) |
Mirror the unsigned long long (exchange the lines A - H, B - G, C - F & D - E.). More... | |
unsigned long long | horizontal_mirror (unsigned long long) |
Mirror the unsigned long long (exchange the line 1 - 8, 2 - 7, 3 - 6 & 4 - 5). More... | |
unsigned int | bswap_int (unsigned int) |
Mirror the unsigned int (little <-> big endian). More... | |
unsigned short | bswap_short (unsigned short) |
Swap bytes of a short (little <-> big endian). More... | |
int | get_rand_bit (unsigned long long, struct Random *) |
Get a random set bit index. More... | |
Variables | |
const unsigned long long | X_TO_BIT [] |
Bitwise operations header file.
#define DLL_API |
#define x_to_bit | ( | x | ) | X_TO_BIT[x] |
Return a bitboard with bit x set.
DLL_API int bit_count | ( | unsigned long long | b | ) |
Count the number of bits set to one in an unsigned long long.
This is the classical popcount function. Since 2007, it is part of the instruction set of some modern CPU, (>= barcelona for AMD or >= nelhacem for Intel). Alternatively, a fast SWAR algorithm, adding bits in parallel is provided here. This function is massively used to count discs on the board, the mobility, or the stability.
b | 64-bit integer to count bits of. |
int bit_weighted_count | ( | const unsigned long long | v | ) |
count the number of discs, counting the corners twice.
This is a variation of the above algorithm to count the mobility and favour the corners. This function is useful for move sorting.
v | 64-bit integer to count bits of. |
void bitboard_write | ( | const unsigned long long | b, |
FILE * | f | ||
) |
Print an unsigned long long as a board.
Write a 64-bit long number as an Othello board.
b | The unsigned long long. |
f | Output stream. |
unsigned int bswap_int | ( | unsigned int | i | ) |
Mirror the unsigned int (little <-> big endian).
i | An unsigned int. |
unsigned short bswap_short | ( | unsigned short | s | ) |
Swap bytes of a short (little <-> big endian).
s | An unsigned short. |
DLL_API int first_bit | ( | unsigned long long | b | ) |
Search the first bit set.
On CPU with AMD64 or EMT64 instructions, a fast asm code is provided. Alternatively, a fast algorithm based on magic numbers is provided.
b | 64-bit integer. |
int get_rand_bit | ( | unsigned long long | b, |
Random * | r | ||
) |
Get a random set bit index.
b | The unsigned long long. |
r | The pseudo-number generator. |
unsigned long long horizontal_mirror | ( | unsigned long long | b | ) |
Mirror the unsigned long long (exchange the line 1 - 8, 2 - 7, 3 - 6 & 4 - 5).
b | An unsigned long long. |
DLL_API int last_bit | ( | unsigned long long | b | ) |
Search the last bit set (same as log2()).
On CPU with AMD64 or EMT64 instructions, a fast asm code is provided. Alternatively, a fast algorithm based on magic numbers is provided.
b | 64-bit integer. |
int next_bit | ( | unsigned long long * | b | ) |
Search the next bit set.
In practice, clear the first bit set and search the next one.
b | 64-bit integer. |
unsigned long long transpose | ( | unsigned long long | b | ) |
Transpose the unsigned long long (symetry % A1-H8 diagonal).
b | An unsigned long long |
unsigned long long vertical_mirror | ( | unsigned long long | b | ) |
Mirror the unsigned long long (exchange the lines A - H, B - G, C - F & D - E.).
b | An unsigned long long |
|
extern |
coordinate to bit table converter