-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
266 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# -- Source Files -- | ||
file(GLOB SOURCES "*.cpp") | ||
|
||
# -- Codfish Engine -- | ||
add_executable(codfish ${SOURCES}) | ||
|
||
# -- Link Libraries -- | ||
target_link_libraries(codfish | ||
PUBLIC codbrain) | ||
|
||
# -- All Warnings as Errors -- | ||
if (MSVC) | ||
target_compile_options(codfish PRIVATE /WX) | ||
else () | ||
target_compile_options(codfish PRIVATE -Werror) | ||
endif () | ||
|
||
# -- Release and Debug Flags -- | ||
if (CMAKE_BUILD_TYPE MATCHES Release) | ||
target_compile_options(codfish PRIVATE -O3 -march=native) | ||
elseif (CMAKE_BUILD_TYPE MATCHES ReleaseCrossPlatform) | ||
target_compile_options(codfish PRIVATE -O3 -march=x86-64) | ||
elseif (CMAKE_BUILD_TYPE MATCHES Debug) | ||
target_compile_options(codfish PRIVATE -g -O0) | ||
target_compile_definitions(codfish PRIVATE DEBUG) | ||
endif () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,37 @@ | ||
#include <codbrain/codbrain.hpp> | ||
|
||
using namespace codchess; | ||
|
||
namespace codbrain { | ||
Brain::Brain() noexcept { | ||
_uci.receive_uci.connect([&]() { | ||
_uci.SendId("Engine name", "Author name"); | ||
_uci.SendOptionUciLimitStrength(false); | ||
_uci.SendUciOk(); | ||
}); | ||
|
||
_uci.receive_is_ready.connect([&]() { _uci.SendReadyOk(); }); | ||
|
||
_uci.receive_position.connect( | ||
[&](const std::string &fen, const std::vector<std::string> &moves) { | ||
_board.FromFen(fen); | ||
for (const auto &move : moves) { | ||
const auto legal = codchess::movegen::Legal(_board); | ||
const auto it = std::find_if(legal.begin(), legal.end(), | ||
[&](const codchess::Move &m) { | ||
return m.ToString() == move; | ||
}); | ||
if (it == legal.end()) { | ||
_uci.SendErrorIllegalMove(); | ||
return; | ||
} else { | ||
_board.Make(*it); | ||
} | ||
} | ||
}); | ||
|
||
_uci.receive_go.connect( | ||
[&](const std::map<Uci::Command, std::string> &) { | ||
const auto result = Search(); | ||
_uci.SendBestMove(result.pv[0].ToString()); | ||
}); | ||
} | ||
} // namespace codbrain |
Oops, something went wrong.