
Right now the engine uses PESTO's evaluation, which I am planning to replace not far in the future.
Moderator: Ras
Very nice...great work!Sazgr wrote: ↑Tue Oct 18, 2022 9:24 pm I have been making a chess engine, named Peacekeeper, for a while. Finally it have gotten to the point where it seems to work decently, with no obvious bugs. Right now, it beats TSCP most of the time (about 80%). Some people might have seen it on GitHub already, but it is on https://github.com/Sazgr/peacekeeper. Most likely, I will use this thread for any further questions.
Right now the engine uses PESTO's evaluation, which I am planning to replace not far in the future.
Code: Select all
#ifdef _MSC_VER
#include <intrin.h>
#endif
#include "typedefs.h"
inline int popcount(u64 bits) {
#ifdef __GNUC__
return __builtin_popcountll(bits);
#elif _MSC_VER
return static_cast<int>(__popcnt64(bits));
#endif
}
inline int get_lsb(u64 bits) {
#ifdef __GNUC__
return __builtin_ctzll(bits);
#elif _MSC_VER
unsigned long idx;
_BitScanForward64(&idx, bits);
return static_cast<int>(idx);
#endif
}
inline int get_msb(u64 bits) {
#ifdef __GNUC__
return __builtin_clzll(bits) ^ 63;
#elif _MSC_VER
unsigned long idx;
_BitScanReverse64(&idx, bits);
return static_cast<int>(idx);
#endif
}
Thank you!dangi12012 wrote: ↑Wed Oct 19, 2022 9:56 pm If you have #pragma once just declare as static in the header and delete this file:
https://github.com/Sazgr/peacekeeper/bl ... magics.cpp
This is also very small:
https://github.com/Sazgr/peacekeeper/bl ... typedefs.h
But its more of a personal preference. I strongly recommend having as little code noise as possible + KISS principle.
since C++17 you can use inline to declare global variables. this way "lookup_table" will only be initialized once.Sazgr wrote: ↑Thu Oct 20, 2022 8:15 pmThank you!dangi12012 wrote: ↑Wed Oct 19, 2022 9:56 pm If you have #pragma once just declare as static in the header and delete this file:
https://github.com/Sazgr/peacekeeper/bl ... magics.cpp
This is also very small:
https://github.com/Sazgr/peacekeeper/bl ... typedefs.h
But its more of a personal preference. I strongly recommend having as little code noise as possible + KISS principle.
I made the magics array static and did delete magics.cpp, however I feel the typedefs file might be expanded in the future.
Sorry if I am being really dumb, but could you give an example of where to add cosntexpr? Thank youtcusr wrote: ↑Thu Oct 20, 2022 10:14 pmsince C++17 you can use inline to declare global variables. this way "lookup_table" will only be initialized once.Sazgr wrote: ↑Thu Oct 20, 2022 8:15 pmThank you!dangi12012 wrote: ↑Wed Oct 19, 2022 9:56 pm If you have #pragma once just declare as static in the header and delete this file:
https://github.com/Sazgr/peacekeeper/bl ... magics.cpp
This is also very small:
https://github.com/Sazgr/peacekeeper/bl ... typedefs.h
But its more of a personal preference. I strongly recommend having as little code noise as possible + KISS principle.
I made the magics array static and did delete magics.cpp, however I feel the typedefs file might be expanded in the future.
i also agree to switch to C++20 so that your code will contain no platform/compiler specific code.
P.S.
i suggest you to use constexpr as much as possible, it will let compiler optimize better and you'll get a noticeable speed up.
anywhere as long as the compiler doesn't complain.Sazgr wrote: ↑Fri Oct 21, 2022 7:26 pmSorry if I am being really dumb, but could you give an example of where to add cosntexpr? Thank youtcusr wrote: ↑Thu Oct 20, 2022 10:14 pmsince C++17 you can use inline to declare global variables. this way "lookup_table" will only be initialized once.Sazgr wrote: ↑Thu Oct 20, 2022 8:15 pmThank you!dangi12012 wrote: ↑Wed Oct 19, 2022 9:56 pm If you have #pragma once just declare as static in the header and delete this file:
https://github.com/Sazgr/peacekeeper/bl ... magics.cpp
This is also very small:
https://github.com/Sazgr/peacekeeper/bl ... typedefs.h
But its more of a personal preference. I strongly recommend having as little code noise as possible + KISS principle.
I made the magics array static and did delete magics.cpp, however I feel the typedefs file might be expanded in the future.
i also agree to switch to C++20 so that your code will contain no platform/compiler specific code.
P.S.
i suggest you to use constexpr as much as possible, it will let compiler optimize better and you'll get a noticeable speed up.![]()
I just modified my eval command to be more informative, the eval command should print the middlegame and endgame PST values, the phase and the weighted PST value now.Robert Pope wrote: ↑Tue Oct 25, 2022 11:58 pm This inspired me to test the PESTO eval in my engine. PESTO was more than twice as fast - really slick use of an array of PSTs compared to how I do it. However, I'm guessing my cut and paste has some bugs, since it performed 300 elo worse than my eval.
Did you implement a static eval command in Peacekeeper? It would be handy to have an independent version to check against.
Code: Select all
position startpos moves e2e4
eval
Code: Select all
middlegame pst: -32
endgame pst: -20
phase: 24
weighted pst: -32