Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,6 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
add_compile_options(/constexpr:steps2000000000 /constexpr:depth1024 /arch:AVX) # I'll assume everybody has this since this is 2025.
endif()

# --- AddressSanitizer for Debug builds ---
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS "Enabling AddressSanitizer")
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(SANITIZER_FLAGS "/fsanitize=address")
else()
message(STATUS "Enabling UndefinedBehaviorSanitizer")
set(SANITIZER_FLAGS "-fsanitize=address -fsanitize=undefined")
endif()
add_compile_options(${SANITIZER_FLAGS})
add_link_options(${SANITIZER_FLAGS})
endif()
add_compile_definitions(GENERATE_AT_RUNTIME)
# --- Core Library ---
set(SOURCES
Expand Down
14 changes: 7 additions & 7 deletions attacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace chess::attacks {
#define _POSSIBLY_CONSTEXPR const
#endif
template <auto AttackFunc, const Bitboard* Magics, size_t TableSize>
_POSSIBLY_CONSTEXPR auto generate_magic_table() {
_POSSIBLY_CONSTEXPR std::pair<std::array<Magic, 64>, std::array<Bitboard, TableSize>> generate_magic_table() {
std::array<Magic, 64> table{};
std::array<Bitboard, TableSize> attacks{};

Expand Down Expand Up @@ -44,13 +44,13 @@ namespace chess::attacks {

return std::pair{ table, attacks };
}
_POSSIBLY_CONSTEXPR auto bishopData =
_POSSIBLY_CONSTEXPR std::pair<std::array<Magic, 64>, std::array<Bitboard, 0x1480>> bishopData =
generate_magic_table<_chess::_HyperbolaBishopAttacks, attacks::BishopMagics, 0x1480>();
_POSSIBLY_CONSTEXPR auto BishopTable = bishopData.first;
_POSSIBLY_CONSTEXPR auto BishopAttacks = bishopData.second;
_POSSIBLY_CONSTEXPR std::array<Magic, 64> BishopTable = bishopData.first;
_POSSIBLY_CONSTEXPR std::array<Bitboard, 0x1480> BishopAttacks = bishopData.second;

_POSSIBLY_CONSTEXPR auto rookData =
_POSSIBLY_CONSTEXPR std::pair<std::array<Magic, 64>, std::array<Bitboard, 0x19000>> rookData =
generate_magic_table<_chess::_HyperbolaRookAttacks, attacks::RookMagics, 0x19000>();
_POSSIBLY_CONSTEXPR auto RookTable = rookData.first;
_POSSIBLY_CONSTEXPR auto RookAttacks = rookData.second;
_POSSIBLY_CONSTEXPR std::array<Magic, 64> RookTable = rookData.first;
_POSSIBLY_CONSTEXPR std::array<Bitboard, 0x19000> RookAttacks = rookData.second;
}
1 change: 1 addition & 0 deletions attacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "bitboard.h"
#include "types.h"
#include <array>
#include <immintrin.h>
namespace chess::attacks {
// clang-format off
// pre-calculated lookup table for pawn attacks
Expand Down