stellar

UCI Chess engine written in C++20
git clone git://git.dimitrijedobrota.com/stellar.git
Log | Files | Refs | README | LICENSE

commit 8bfcf04517460ec1e051df56703b6881d64f279c
parent 2f3a26c1d985412b453547ebd5c01190e378684e
author Dimitrije Dobrota <mail@dimitrijedobrota.com>
date Wed, 13 Mar 2024 20:13:38 +0000

Move bitboard from utils and cleanup CMakeList.txt

Diffstat:
M CMakeLists.txt | + -
M src/arena/CMakeLists.txt | ++ -
M src/attack/CMakeLists.txt | ---
A src/bitboard/CMakeLists.txt | ++
A src/bitboard/bitboard.cpp | ++++++++++++++++++++++
A src/bitboard/bitboard.hpp | ++++++++++++++++++++++++++
M src/board/CMakeLists.txt | ++ -
M src/engine/CMakeLists.txt | ++ -
M src/move/CMakeLists.txt | ++ -
M src/perft/CMakeLists.txt | +
M src/piece/CMakeLists.txt | -
M src/utils/CMakeLists.txt | ---------------
D src/utils/bitboard.cpp | ----------------------
D src/utils/bitboard.hpp | --------------------------

14 files changed, 60 insertions(+), 72 deletions(-)


diff --git a/ CMakeLists.txt b/ CMakeLists.txt

@@ -3,7 +3,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) project( Stellar
VERSION 1.3.1
VERSION 1.3.2
DESCRIPTION "Chess engine written in C++" HOMEPAGE_URL https://git.dimitrijedobrota.com/stellar.git LANGUAGES CXX

diff --git a/ src/arena/CMakeLists.txt b/ src/arena/CMakeLists.txt

@@ -1,12 +1,13 @@ add_executable(arena arena.cpp
match.cpp
engine.cpp game.cpp
match.cpp
) target_link_libraries(arena PRIVATE Stellar_version
PRIVATE bitboard
PRIVATE board PRIVATE moves PRIVATE piece

diff --git a/ src/attack/CMakeLists.txt b/ src/attack/CMakeLists.txt

@@ -1,10 +1,7 @@ add_library(attack attack.cpp bishop.cpp rook.cpp) target_link_libraries(attack
PRIVATE bit
PRIVATE bitboard
PRIVATE color
PRIVATE square
PRIVATE utils )

diff --git a/ src/bitboard/CMakeLists.txt b/ src/bitboard/CMakeLists.txt

@@ -0,0 +1,2 @@
add_library(bitboard INTERFACE)
target_include_directories(bitboard INTERFACE .)

diff --git a/ src/bitboard/bitboard.cpp b/ src/bitboard/bitboard.cpp

@@ -0,0 +1,22 @@
#include "bitboard.hpp"
#include "bit.hpp"
#include <iostream>
namespace bitboard {
void print(U64 bitboard) {
for (int rank = 0; rank < 8; rank++) {
for (int file = 0; file < 8; file++) {
uint8_t square = (7 - rank) * 8 + file;
if (!file) printf(" %d ", 8 - rank);
std::cout << bit::get(bitboard, square) << " ";
}
std::cout << "\n";
}
std::cout << "\n A B C D E F G H\n\n";
std::cout << " Bitboard: " << std::hex << bitboard << std::dec << std::endl;
}
} // namespace bitboard

diff --git a/ src/bitboard/bitboard.hpp b/ src/bitboard/bitboard.hpp

@@ -0,0 +1,26 @@
#ifndef STELLAR_BITBOARD_H
#define STELLAR_BITBOARD_H
#include "square.hpp"
#include "utils.hpp"
namespace bitboard {
void print(U64 bitboard);
inline constexpr const U64 notAFile = C64(0xfefefefefefefefe);
inline constexpr const U64 notHFile = C64(0x7f7f7f7f7f7f7f7f);
typedef U64 (*direction_f)(U64);
inline constexpr U64 soutOne(U64 b) { return b >> 8; }
inline constexpr U64 nortOne(U64 b) { return b << 8; }
inline constexpr U64 eastOne(U64 b) { return (b & notHFile) << 1; }
inline constexpr U64 westOne(U64 b) { return (b & notAFile) >> 1; }
inline constexpr U64 soEaOne(U64 b) { return (b & notHFile) >> 7; }
inline constexpr U64 soWeOne(U64 b) { return (b & notAFile) >> 9; }
inline constexpr U64 noEaOne(U64 b) { return (b & notHFile) << 9; }
inline constexpr U64 noWeOne(U64 b) { return (b & notAFile) << 7; }
} // namespace bitboard
#endif

diff --git a/ src/board/CMakeLists.txt b/ src/board/CMakeLists.txt

@@ -3,8 +3,9 @@ add_library(board OBJECT ) target_link_libraries(board
PRIVATE bitboard
PRIVATE utils
PUBLIC piece
PRIVATE piece
PUBLIC random )

diff --git a/ src/engine/CMakeLists.txt b/ src/engine/CMakeLists.txt

@@ -1,12 +1,13 @@ add_executable(engine
engine.cpp
evaluate.cpp uci.cpp
engine.cpp
) target_link_libraries(engine PRIVATE Stellar_version
PRIVATE bitboard
PRIVATE board PRIVATE moves PRIVATE piece

diff --git a/ src/move/CMakeLists.txt b/ src/move/CMakeLists.txt

@@ -4,8 +4,9 @@ add_library(moves OBJECT ) target_link_libraries(moves
PRIVATE piece
PRIVATE bitboard
PRIVATE board
PRIVATE piece
PRIVATE utils )

diff --git a/ src/perft/CMakeLists.txt b/ src/perft/CMakeLists.txt

@@ -6,6 +6,7 @@ if(STELLAR_FULL_COUNT) endif() target_link_libraries(perft
PRIVATE bitboard
PRIVATE board PRIVATE moves PRIVATE piece

diff --git a/ src/piece/CMakeLists.txt b/ src/piece/CMakeLists.txt

@@ -3,7 +3,6 @@ add_library(piece INTERFACE) target_link_libraries(piece INTERFACE attack INTERFACE utils
INTERFACE color
) target_include_directories(piece INTERFACE .)

diff --git a/ src/utils/CMakeLists.txt b/ src/utils/CMakeLists.txt

@@ -1,17 +1,2 @@
add_library(bit INTERFACE)
target_include_directories(bit INTERFACE .)
add_library(bitboard INTERFACE bitboard.cpp)
target_include_directories(bitboard INTERFACE .)
add_library(color INTERFACE)
target_include_directories(color INTERFACE .)
add_library(square INTERFACE)
target_include_directories(square INTERFACE .)
add_library(timer INTERFACE)
target_include_directories(timer INTERFACE .)
add_library(utils INTERFACE) target_include_directories(utils INTERFACE .)

diff --git a/ src/utils/bitboard.cpp b/ src/utils/bitboard.cpp

@@ -1,22 +0,0 @@
#include "bitboard.hpp"
#include "bit.hpp"
#include <iostream>
namespace bitboard {
void print(U64 bitboard) {
for (int rank = 0; rank < 8; rank++) {
for (int file = 0; file < 8; file++) {
uint8_t square = (7 - rank) * 8 + file;
if (!file) printf(" %d ", 8 - rank);
std::cout << bit::get(bitboard, square) << " ";
}
std::cout << "\n";
}
std::cout << "\n A B C D E F G H\n\n";
std::cout << " Bitboard: " << std::hex << bitboard << std::dec << std::endl;
}
} // namespace bitboard

diff --git a/ src/utils/bitboard.hpp b/ src/utils/bitboard.hpp

@@ -1,26 +0,0 @@
#ifndef STELLAR_BITBOARD_H
#define STELLAR_BITBOARD_H
#include "square.hpp"
#include "utils.hpp"
namespace bitboard {
void print(U64 bitboard);
inline constexpr const U64 notAFile = C64(0xfefefefefefefefe);
inline constexpr const U64 notHFile = C64(0x7f7f7f7f7f7f7f7f);
typedef U64 (*direction_f)(U64);
inline constexpr U64 soutOne(U64 b) { return b >> 8; }
inline constexpr U64 nortOne(U64 b) { return b << 8; }
inline constexpr U64 eastOne(U64 b) { return (b & notHFile) << 1; }
inline constexpr U64 westOne(U64 b) { return (b & notAFile) >> 1; }
inline constexpr U64 soEaOne(U64 b) { return (b & notHFile) >> 7; }
inline constexpr U64 soWeOne(U64 b) { return (b & notAFile) >> 9; }
inline constexpr U64 noEaOne(U64 b) { return (b & notHFile) << 9; }
inline constexpr U64 noWeOne(U64 b) { return (b & notAFile) << 7; }
} // namespace bitboard
#endif