Hi there !mvanthoor wrote: ↑Sat Feb 15, 2020 5:16 pm Congratulations on your first release
I am thrilled to read that you are starting from scratch without using another engine as a reference. It's a lot of work, but that way, you can establish a baseline ELO, and see the strength gains your engine makes with each new function you implement. (In the beginning, those gains will be positively huge; possibly >100 ELO for implementing a search optimization or an extra evaluation parameter. Search Madchess.net for more info. Erik Madsen chronicled the development of Madchess 2 and 3 after establishing the baseline.)
I've looked at your code. Congratulations about that as well. It's one of the most readable implementations I've seen in a long time. It avoids the pitfall of having lots of if/switch/for/while blocks wrapped into one-another. If you remove the numbers that appear throughout (replace them by constants) and add a lot of comments, this could be a great reference engine.
It compiles cleanly under Windows (MSYS2 / MinGW64). A suggestion: change the build script so it compiles statically. Now you need to have libwinpthread-1.dll in the same folder as stash-bot.exe. This is just a matter of taste obviously, but in the case of chess engines, my preference is to have a single executable that works without any dependencies.
===
As an aside: Some months ago, I _finally_ started writing my own chess engine, using the Rust programming language. (My one constraint with regard to writing a chess engine is to NOT use C or C++, because everybody and their dog has a C/C++ chess engine. C/C++ are fast, but they're also ancient with lots of pitfalls.)
Your engine seems to use board iteration to find the pieces, and then iterates over the squares in each direction the piece can move. My engine is using magic bitboards, and I've just reached the stage where I start to implement the move generator. (I reserve the engine name to for myself, because I haven't decided yet :p)
I can't wait to finish by engine to a playable baseline and then pit it against this version of Stash, because they're both original, not derived from any other engines, in the beginning stages of development, they use different programming languages, and different board representations.
Good luck to you
(Some output of the partially complete move generator of my engine...)
Code: Select all
Finished dev [unoptimized + debuginfo] target(s) in 0.54s Running `target\debug\xyz.exe` Engine: xyz Author: mvanthoor 8 . . . r . . . . 7 . . b k . . . . 6 . . . I N . . . 5 . . . . . . . i 4 . i I . . n . . 3 . . . i . . . I 2 N n . . . . . . 1 K R . B . . . . A B C D E F G H Kd7d6 (capture) Kd7e6 (capture) Kd7c6 (normal) Kd7e7 (normal) Kd7c8 (normal) Kd7e8 (normal) Nb2d1 (capture) Nb2c4 (capture) Nb2a4 (normal) Nf4h3 (capture) Nf4e6 (capture) Nf4e2 (normal) Nf4g2 (normal) Nf4d5 (normal) Nf4g6 (normal) Done.
As you pointed out, my code was not that commented, so I started clarifying a bit things on the search function ^^ I also added static compilation to the build.sh script. I have been looking at how to use magic bitboards on a chess engine, but it will ask a lot of refactorization, so I'm planning to work on that in parallel of the algorithm optimization.
Also Guenther, the CPU consuming was due to an incorrect implementation of the wait for the engine to launch, so it should be fixed now
The multithreading implementation is very doubtful for now, so letting the Threads parameter as is is preferable.