-
Notifications
You must be signed in to change notification settings - Fork 0
/
bitboard.cpp
executable file
·65 lines (54 loc) · 1.2 KB
/
bitboard.cpp
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
/**********************************************************************
|
| Bogart
| Chess Engine
|
| Copyright (C) 2009-2013 Dr.Kameleon
|
|**********************************************************************
| bitboard.cpp
|**********************************************************************/
#include "bogart.h"
//=======================================================
// Output
//=======================================================
const char* Bitboard::str(U64 bitboard)
{
static char b[65];
b[0] = '\0';
for (U64 z = (1ULL<<63); z > 0; z >>= 1)
{
strcat(b, ((bitboard & z) == z) ? "1" : "0");
}
return b;
}
string Bitboard::out(U64 bitboard)
{
string res = "";
for (int i=63; i>=0; i--)
{
U64 position = 1ULL<<i;
(bitboard&position)==position ? res += "X " : res += ". ";
if (i%8==0) res += "\n";
}
return res;
}
string Bitboard::outAndMark(U64 bitboard, int pos)
{
string res = "";
for (int i=63; i>=0; i--)
{
U64 position = 1ULL<<i;
if (i==pos) res+= "O ";
else
{
(bitboard&position)==position ? res += "X " : res += ". ";
}
if (i%8==0) res += "\n";
}
return res;
}
void Bitboard::print(U64 bitboard)
{
cout << Bitboard::out(bitboard);
}