BenBot
1.7.5
A chess engine
Loading...
Searching...
No Matches
Flips.hpp
Go to the documentation of this file.
1
/*
2
* ======================================================================================
3
*
4
* ░▒▓███████▓▒░░▒▓████████▓▒░▒▓███████▓▒░ ░▒▓███████▓▒░ ░▒▓██████▓▒░▒▓████████▓▒░
5
* ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
6
* ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
7
* ░▒▓███████▓▒░░▒▓██████▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
8
* ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
9
* ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
10
* ░▒▓███████▓▒░░▒▓████████▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓███████▓▒░ ░▒▓██████▓▒░ ░▒▓█▓▒░
11
*
12
* ======================================================================================
13
*/
14
19
20
#pragma once
21
22
#include <bit>
23
#include <
libchess/board/Bitboard.hpp
>
24
28
namespace
chess::board::flips
{
29
33
[[nodiscard, gnu::const]]
constexpr
auto
vertical
(
Bitboard
board
)
noexcept
->
Bitboard
;
34
38
[[nodiscard, gnu::const]]
constexpr
auto
horizontal
(
Bitboard
board
)
noexcept
->
Bitboard
;
39
40
/*
41
___ ,--,
42
,---, ,--.'|_ ,--, ,--.'|
43
,---.'| | | :,' ,--.'| | | :
44
| | : : : ' : | |, : : ' .--.--.
45
| | | ,---. .;__,' / ,--.--. `--'_ | ' | / / '
46
,--.__| | / \ | | | / \ ,' ,'| ' | | | : /`./
47
/ ,' | / / |:__,'| : .--. .-. | ' | | | | : | : ;_
48
. ' / |. ' / | ' : |__ \__\/: . . | | : ' : |__ \ \ `.
49
' ; |: |' ; /| | | '.'| ," .--.; | ' : |__ | | '.'| `----. \
50
| | '/ '' | / | ; : ;/ / ,. | | | '.'|; : ;/ /`--' /__ ___ ___
51
| : :|| : | | , /; : .' \; : ;| , /'--'. / .\/ .\/ .\
52
\ \ / \ \ / ---`-' | , .-./| , / ---`-' `--'---'\ ; \ ; \ ; |
53
`----' `----' `--`---' ---`-' `--" `--" `--"
54
55
*/
56
57
constexpr
auto
vertical
(
const
Bitboard
board
)
noexcept
->
Bitboard
58
{
59
return
Bitboard
{
60
std::byteswap(
board
.to_int())
61
};
62
}
63
64
constexpr
auto
horizontal
(
Bitboard
board
)
noexcept
->
Bitboard
65
{
66
using namespace
literals
;
// NOLINT(build/namespaces_literals)
67
68
static
constexpr
auto
msk1 = 0x5555555555555555_bb;
69
static
constexpr
auto
msk2 = 0x3333333333333333_bb;
70
static
constexpr
auto
msk4 = 0x0f0f0f0f0f0f0f0f_bb;
71
72
board
= ((
board
>> 1uz) & msk1) | ((
board
& msk1) << 1uz);
73
board
= ((
board
>> 2uz) & msk2) | ((
board
& msk2) << 2uz);
74
board
= ((
board
>> 4uz) & msk4) | ((
board
& msk4) << 4uz);
75
76
return
board
;
77
}
78
79
}
// namespace chess::board::flips
Bitboard.hpp
chess::board::flips::horizontal
constexpr auto horizontal(Bitboard board) noexcept -> Bitboard
Definition
Flips.hpp:64
chess::board::flips::vertical
constexpr auto vertical(Bitboard board) noexcept -> Bitboard
Definition
Flips.hpp:57
chess::board::flips
Definition
Flips.hpp:28
chess::board::literals
Definition
Bitboard.hpp:238
chess::board
Definition
Bitboard.hpp:33
chess::board::Bitboard
Definition
Bitboard.hpp:48
libchess
include
libchess
board
Flips.hpp
Generated on
for BenBot by
1.16.1