Skip to content

Commit

Permalink
We're building a new brain, from scratch
Browse files Browse the repository at this point in the history
  • Loading branch information
jsilll committed Jun 22, 2023
1 parent 69483ee commit a43163d
Show file tree
Hide file tree
Showing 28 changed files with 76 additions and 1,119 deletions.
2 changes: 1 addition & 1 deletion codbrain/docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ set(DOXYGEN_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
file(GLOB_RECURSE HEADERS ../include/codbrain/*.hpp)

# -- Building Documentation --
doxygen_add_docs(codchess-docs ${HEADERS} COMMENT "Generating Documentation for CodBrain")
doxygen_add_docs(docs_codchess ${HEADERS} COMMENT "Generating Documentation for CodBrain")
16 changes: 8 additions & 8 deletions codbrain/examples/simple/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
file(GLOB_RECURSE SOURCES *.cpp)

# -- Executable --
add_executable(codbrain_example_simple ${SOURCES})
add_executable(example_simple_codbrain ${SOURCES})

target_link_libraries(codbrain_example_simple PRIVATE codbrain)
target_link_libraries(example_simple_codbrain PRIVATE codbrain)

# -- All Warnings as Errors --
if (MSVC)
target_compile_options(codbrain_example_simple PRIVATE /WX)
target_compile_options(example_simple_codbrain PRIVATE /WX)
else ()
target_compile_options(codbrain_example_simple PRIVATE -Werror)
target_compile_options(example_simple_codbrain PRIVATE -Werror)
endif ()

# -- Release and Debug Flags --
if (CMAKE_BUILD_TYPE MATCHES Release)
target_compile_options(codbrain_example_simple PRIVATE -O3 -march=native)
target_compile_options(example_simple_codbrain PRIVATE -O3 -march=native)
elseif (CMAKE_BUILD_TYPE MATCHES ReleaseCrossPlatform)
target_compile_options(codbrain_example_simple PRIVATE -O3 -march=x86-64)
target_compile_options(example_simple_codbrain PRIVATE -O3 -march=x86-64)
elseif (CMAKE_BUILD_TYPE MATCHES Debug)
target_compile_options(codbrain_example_simple PRIVATE -g -O0)
target_compile_definitions(codbrain_example_simple PRIVATE DEBUG)
target_compile_options(example_simple_codbrain PRIVATE -g -O0)
target_compile_definitions(example_simple_codbrain PRIVATE DEBUG)
endif ()
173 changes: 0 additions & 173 deletions codbrain/include/codbrain/brain.hpp

This file was deleted.

43 changes: 39 additions & 4 deletions codbrain/include/codbrain/codbrain.hpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,46 @@
#pragma once

#include <codbrain/brain.hpp>
#include <codchess/codchess.hpp>

namespace codbrain {
/// @brief Initializes the library
void Init() noexcept {
eval::Init();
void
Init() noexcept {
codchess::Init();
}
} // namespace codbrain

/// @brief The depth of the search.
typedef std::uint8_t Depth;

/// @brief The number of nodes searched.
typedef std::uint64_t Nodes;

/// @brief The evaluation of a position.
typedef std::int16_t Evaluation;

struct Result {
Nodes nodes;
Evaluation evaluation;
std::vector<codchess::Move> pv;
};

class Brain final {
public:
/// @brief Construct a new Brain object.
explicit Brain(const Depth depth) noexcept : _depth{depth} {}

/// @brief Returns the board.
[[nodiscard]] auto &board() noexcept { return _board; }

/// @brief Returns the best move.
[[nodiscard]] Result Search() noexcept {
const auto legal_moves = codchess::movegen::Legal(_board);
return {0, 0, {*legal_moves.begin()}};
}

private:
Depth _depth;
/// @brief The board.
codchess::Board _board{};
};
} // namespace codbrain
18 changes: 0 additions & 18 deletions codbrain/include/codbrain/eval.hpp

This file was deleted.

36 changes: 0 additions & 36 deletions codbrain/include/codbrain/histmoves.hpp

This file was deleted.

42 changes: 0 additions & 42 deletions codbrain/include/codbrain/histtable.hpp

This file was deleted.

Loading

0 comments on commit a43163d

Please sign in to comment.