Witek902 / Caissa

Strong chess engine
MIT License
63 stars 10 forks source link

compile on Linux ? #2

Closed tissatussa closed 1 year ago

tissatussa commented 1 year ago

is the source code also for Linux ? I guess not .. after doing cmake -DCMAKE_BUILD_TYPE=Debug i get a makefile .. then i do make but i get these errors :

~/Compiled/Caissa$ make
[  2%] Building CXX object src/backend/CMakeFiles/backend.dir/Bitboard.cpp.o
[  4%] Building CXX object src/backend/CMakeFiles/backend.dir/Common.cpp.o
[  6%] Building CXX object src/backend/CMakeFiles/backend.dir/Endgame.cpp.o
[  8%] Building CXX object src/backend/CMakeFiles/backend.dir/Evaluate.cpp.o
In file included from /home/roelof/Compiled/Caissa/src/backend/Evaluate.cpp:8:
/home/roelof/Compiled/Caissa/src/backend/Search.hpp:247:44: error: ‘unique_ptr’ in namespace ‘std’ does not name a template type
  247 |         using NNEvaluatorContextPtr = std::unique_ptr<NNEvaluatorContext>;
      |                                            ^~~~~~~~~~
/home/roelof/Compiled/Caissa/src/backend/Search.hpp:8:1: note: ‘std::unique_ptr’ is defined in header ‘<memory>’; did you forget to ‘#include <memory>’?
    7 | #include "Memory.hpp"
  +++ |+#include <memory>
    8 | #include "NeuralNetworkEvaluator.hpp"
/home/roelof/Compiled/Caissa/src/backend/Search.hpp:248:9: error: ‘NNEvaluatorContextPtr’ does not name a type; did you mean ‘NNEvaluatorContext’?
  248 |         NNEvaluatorContextPtr nnContextStack[MaxSearchDepth];
      |         ^~~~~~~~~~~~~~~~~~~~~
      |         NNEvaluatorContext
cc1plus: note: unrecognized command-line option ‘-Wno-four-char-constants’ may have been intended to silence earlier diagnostics
cc1plus: note: unrecognized command-line option ‘-Wno-nested-anon-types’ may have been intended to silence earlier diagnostics
cc1plus: note: unrecognized command-line option ‘-Wno-gnu-anonymous-struct’ may have been intended to silence earlier diagnostics
make[2]: *** [src/backend/CMakeFiles/backend.dir/build.make:118: src/backend/CMakeFiles/backend.dir/Evaluate.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:149: src/backend/CMakeFiles/backend.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
Witek902 commented 1 year ago

Should be fixed in latest commit. Keep in mind it's not well tested on Linux as it's not my primary platform.

tissatussa commented 1 year ago

thanks for the quick fix! now i was able to compile Caissa v1.3 on my Xubuntu 22.04, although i got a few warnings, see below. then, while executing the binary, it displayed 2 (same?) lines saying "Failed to load default neural network eval-119EA6E0.pnn" .. the options show that "EvalFile eval-119EA6E0.pnn" and "EndgameEvalFile endgame-9AE58CC2.pnn" will be used, but those files are not included .. however, Caissa v1.3 plays chess in CuteChess, so i guess those eval files are embedded ? Maybe not, because Caissa lost my first game against a 2800 ELO engine, but the CCRL list shows Caissa v1.2 has 3293 (!) ELO, so it should win .. Could you provide those .pnn files ?

~/Compiled/Caissa$ cmake -DCMAKE_BUILD_TYPE=Debug
CMake Warning:
  No source or binary directory provided.  Both will be assumed to be the
  same as the current working directory, but note that this warning will
  become a fatal error in future CMake releases.

CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- The C compiler identification is GNU 11.3.0
-- The CXX compiler identification is GNU 11.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Building in Debug configuration
-- Configuring done
-- Generating done
-- Build files have been written to: /home/roelof/Compiled/Caissa

~/Compiled/Caissa$ make
[  2%] Building CXX object src/backend/CMakeFiles/backend.dir/Bitboard.cpp.o
[  4%] Building CXX object src/backend/CMakeFiles/backend.dir/Common.cpp.o
[  6%] Building CXX object src/backend/CMakeFiles/backend.dir/Endgame.cpp.o
[  8%] Building CXX object src/backend/CMakeFiles/backend.dir/Evaluate.cpp.o
[ 10%] Building CXX object src/backend/CMakeFiles/backend.dir/Game.cpp.o
[ 12%] Building CXX object src/backend/CMakeFiles/backend.dir/Material.cpp.o
[ 14%] Building CXX object src/backend/CMakeFiles/backend.dir/Memory.cpp.o
[ 16%] Building CXX object src/backend/CMakeFiles/backend.dir/Move.cpp.o
[ 18%] Building CXX object src/backend/CMakeFiles/backend.dir/MoveList.cpp.o
[ 20%] Building CXX object src/backend/CMakeFiles/backend.dir/MoveOrderer.cpp.o
[ 22%] Building CXX object src/backend/CMakeFiles/backend.dir/MovePicker.cpp.o
[ 25%] Building CXX object src/backend/CMakeFiles/backend.dir/NeuralNetworkEvaluator.cpp.o
[ 27%] Building CXX object src/backend/CMakeFiles/backend.dir/PGNParser.cpp.o
[ 29%] Building CXX object src/backend/CMakeFiles/backend.dir/PSQT.cpp.o
[ 31%] Building CXX object src/backend/CMakeFiles/backend.dir/PackedNeuralNetwork.cpp.o
[ 33%] Building CXX object src/backend/CMakeFiles/backend.dir/Position.cpp.o
[ 35%] Building CXX object src/backend/CMakeFiles/backend.dir/PositionHash.cpp.o
[ 37%] Building CXX object src/backend/CMakeFiles/backend.dir/PositionUtils.cpp.o
[ 39%] Building CXX object src/backend/CMakeFiles/backend.dir/Search.cpp.o
/home/roelof/Compiled/Caissa/src/backend/Search.cpp: In member function ‘void Search::BuildMoveReductionTable()’:
/home/roelof/Compiled/Caissa/src/backend/Search.cpp:96:35: warning: comparison of integer expressions of different signedness: ‘int32_t’ {aka ‘int’} and ‘const uint32_t’ {aka ‘const unsigned int’} [-Wsign-compare]
   96 |     for (int32_t depth = 1; depth < LMRTableSize; ++depth)
      |                             ~~~~~~^~~~~~~~~~~~~~
/home/roelof/Compiled/Caissa/src/backend/Search.cpp: In member function ‘ScoreType Search::NegaMax(Search::ThreadData&, NodeInfo&, Search::SearchContext&) const’:
/home/roelof/Compiled/Caissa/src/backend/Search.cpp:1365:13: warning: variable ‘singularScoreDiff’ set but not used [-Wunused-but-set-variable]
 1365 |     int32_t singularScoreDiff = 0;
      |             ^~~~~~~~~~~~~~~~~
At global scope:
cc1plus: note: unrecognized command-line option ‘-Wno-four-char-constants’ may have been intended to silence earlier diagnostics
cc1plus: note: unrecognized command-line option ‘-Wno-nested-anon-types’ may have been intended to silence earlier diagnostics
cc1plus: note: unrecognized command-line option ‘-Wno-gnu-anonymous-struct’ may have been intended to silence earlier diagnostics
[ 41%] Building CXX object src/backend/CMakeFiles/backend.dir/SearchUtils.cpp.o
[ 43%] Building CXX object src/backend/CMakeFiles/backend.dir/Square.cpp.o
[ 45%] Building CXX object src/backend/CMakeFiles/backend.dir/Tablebase.cpp.o
[ 47%] Building CXX object src/backend/CMakeFiles/backend.dir/Time.cpp.o
[ 50%] Building CXX object src/backend/CMakeFiles/backend.dir/TimeManager.cpp.o
[ 52%] Building CXX object src/backend/CMakeFiles/backend.dir/TranspositionTable.cpp.o
[ 54%] Building CXX object src/backend/CMakeFiles/backend.dir/Waitable.cpp.o
[ 56%] Linking CXX static library ../../lib/libbackend.a
[ 56%] Built target backend
[ 58%] Building CXX object src/frontend/CMakeFiles/caissa.dir/Main.cpp.o
[ 60%] Building CXX object src/frontend/CMakeFiles/caissa.dir/UCI.cpp.o
[ 62%] Linking CXX executable ../../bin/caissa
[ 62%] Built target caissa
[ 64%] Building CXX object src/utils/CMakeFiles/utils.dir/AnalyzeGames.cpp.o
[ 66%] Building CXX object src/utils/CMakeFiles/utils.dir/EndgameNetworkTrainer.cpp.o
[ 68%] Building CXX object src/utils/CMakeFiles/utils.dir/EndgamePieceSquareTables.cpp.o
[ 70%] Building CXX object src/utils/CMakeFiles/utils.dir/EndgameValidation.cpp.o
[ 72%] Building CXX object src/utils/CMakeFiles/utils.dir/GameCollection.cpp.o
[ 75%] Building CXX object src/utils/CMakeFiles/utils.dir/GameTests.cpp.o
[ 77%] Building CXX object src/utils/CMakeFiles/utils.dir/Main.cpp.o
[ 79%] Building CXX object src/utils/CMakeFiles/utils.dir/NetworkTest.cpp.o
[ 81%] Building CXX object src/utils/CMakeFiles/utils.dir/NetworkTrainer.cpp.o
[ 83%] Building CXX object src/utils/CMakeFiles/utils.dir/NeuralNetwork.cpp.o
/home/roelof/Compiled/Caissa/src/utils/NeuralNetwork.cpp: In member function ‘void nn::Layer::UpdateWeights(float, const nn::Gradients&, float, float, float, float)’:
/home/roelof/Compiled/Caissa/src/utils/NeuralNetwork.cpp:720:18: warning: unused variable ‘signMaskVec’ [-Wunused-variable]
  720 |     const __m256 signMaskVec = _mm256_castsi256_ps(_mm256_set1_epi32(0x80000000));
      |                  ^~~~~~~~~~~
At global scope:
cc1plus: note: unrecognized command-line option ‘-Wno-four-char-constants’ may have been intended to silence earlier diagnostics
cc1plus: note: unrecognized command-line option ‘-Wno-nested-anon-types’ may have been intended to silence earlier diagnostics
cc1plus: note: unrecognized command-line option ‘-Wno-gnu-anonymous-struct’ may have been intended to silence earlier diagnostics
[ 85%] Building CXX object src/utils/CMakeFiles/utils.dir/PackedPositionTests.cpp.o
[ 87%] Building CXX object src/utils/CMakeFiles/utils.dir/PieceSquareTablesTrainer.cpp.o
/home/roelof/Compiled/Caissa/src/utils/PieceSquareTablesTrainer.cpp: In function ‘void PositionToTrainingVector(const Position&, nn::TrainingVector&)’:
/home/roelof/Compiled/Caissa/src/utils/PieceSquareTablesTrainer.cpp:89:20: warning: variable ‘whitePawnsFlipped’ set but not used [-Wunused-but-set-variable]
   89 |     const Bitboard whitePawnsFlipped = pos.Whites().pawns.MirroredVertically();
      |                    ^~~~~~~~~~~~~~~~~
At global scope:
cc1plus: note: unrecognized command-line option ‘-Wno-four-char-constants’ may have been intended to silence earlier diagnostics
cc1plus: note: unrecognized command-line option ‘-Wno-nested-anon-types’ may have been intended to silence earlier diagnostics
cc1plus: note: unrecognized command-line option ‘-Wno-gnu-anonymous-struct’ may have been intended to silence earlier diagnostics
[ 89%] Building CXX object src/utils/CMakeFiles/utils.dir/SelfPlay.cpp.o
/home/roelof/Compiled/Caissa/src/utils/SelfPlay.cpp: In lambda function:
/home/roelof/Compiled/Caissa/src/utils/SelfPlay.cpp:244:29: warning: variable ‘startTimePoint’ set but not used [-Wunused-but-set-variable]
  244 |             const TimePoint startTimePoint = TimePoint::GetCurrent();
      |                             ^~~~~~~~~~~~~~
At global scope:
cc1plus: note: unrecognized command-line option ‘-Wno-four-char-constants’ may have been intended to silence earlier diagnostics
cc1plus: note: unrecognized command-line option ‘-Wno-nested-anon-types’ may have been intended to silence earlier diagnostics
cc1plus: note: unrecognized command-line option ‘-Wno-gnu-anonymous-struct’ may have been intended to silence earlier diagnostics
[ 91%] Building CXX object src/utils/CMakeFiles/utils.dir/Stream.cpp.o
[ 93%] Building CXX object src/utils/CMakeFiles/utils.dir/Tests.cpp.o
[ 95%] Building CXX object src/utils/CMakeFiles/utils.dir/ThreadPool.cpp.o
[ 97%] Building CXX object src/utils/CMakeFiles/utils.dir/TrainerCommon.cpp.o
[100%] Linking CXX executable ../../bin/utils
[100%] Built target utils

~/Compiled/Caissa/bin$ ./caissa 
Caissa 1.3 by Michal Witanowski
info string Failed to load default neural network eval-119EA6E0.pnn
info string Failed to load default neural network eval-119EA6E0.pnn
uci
id name Caissa 1.3
id author Michal Witanowski
option name Hash type spin default 256 min 1 max 1048576
option name MultiPV type spin default 1 min 1 max 255
option name MoveOverhead type spin default 10 min 0 max 10000
option name Threads type spin default 1 min 1 max 1024
option name Ponder type check default false
option name EvalFile type string default eval-119EA6E0.pnn
option name EndgameEvalFile type string default endgame-9AE58CC2.pnn
option name SyzygyPath type string default <empty>
option name GaviotaTbPath type string default <empty>
option name GaviotaTbCache type spin default 64 min 1 max 1048576
option name UCI_AnalyseMode type check default false
option name UCI_Chess960 type check default false
option name UseSAN type check default false
option name ColorConsoleOutput type check default false
option name TunedParam type spin default 0 min -1000000 max 1000000
uciok
Witek902 commented 1 year ago

Indeed, the network files are not present in git repo. You need to extract them from latest release: https://github.com/Witek902/Caissa/releases/tag/1.3 The engine without net is ~500 Elo points weaker.

tissatussa commented 1 year ago

thanks. i did that and all goes well. indeed, now Caissa no-NNUE lost against that 2800 engine, and Caissa NNUE won .. what are those .pnn files? Are they some .nnue with a different extension, or are they some own NN format?

And did you really start programming Caissa in 2021 ? Then rating 3200+ is impressive! Or did you use StockFish code? Just saying ..

Witek902 commented 1 year ago

PNN stands for "packed neural network". It's my own NNUE implementation, but much simpler than in Stockfish. I don't use king-relative features, just absolute piece positions, so it's much smaller (700KB vs 20MB in SF) and weaker. All the code for probing, tuning, etc. is in the repository. Yes, I started coding in the beginning of 2021, and I keep working on it since then. Of course, I was heavily inspired by top engines. ~3400 rating is indeed quite satisfying, but I think I hit a wall and it's really hard to progress any further...