Heiaha / Weiawaga

A UCI chess engine written in Rust.
GNU General Public License v2.0
43 stars 0 forks source link

Open to contributions? #8

Closed matthieu closed 1 year ago

matthieu commented 1 year ago

Hi,

I was wondering if you were open to contributions or preferred to keep Weiawaga as a 100% personal project? There are a few areas for which I think I could propose small PRs that could be valuable. For example:

Either way, congratulations on Weiawaga! You did an awesome job implementing quite a few state-of-art chess engine features while keeping the code clean and concise.

Heiaha commented 1 year ago

Hi!

Yes, unfortunately since this is just a personal passion project I would prefer to keep it closed to contributions. I'm always open to suggestions, but as for actually implementing anything I'd rather do that all myself. I wasn't aware of the inlining nuances, so I definitely appreciate the suggestion on that!

Some of the things you've pointed out are definitely weaknesses in the current code. I have had it high on my task list to port some things in the code to iterators, including the parts of the NNUE implementation you've pointed and also the repetition checking, for example. Personally I don't have much experience with this style of coding so I've mostly (and badly) opted to shy away from it, but that's something I definitely want to change.

On my longer to do list is to explicitly add code to handle SIMD to the NNUE at some point, although I've put that off for now since the NNUE implementation is still pretty naive and I've wanted to make things more robust on that front before trying to do an explicit SIMD implementation with something like std::simd.

On the unsafe code, I've gone back and forth with myself a bit on keeping things unsafe in those few spots or using lazy_static. At this point I've consciously opted for keeping the dependencies down, although that may change in the future. I think originally I opted for unsafe code because it wasn't clear to me at first glance that there was a clean way to do the fancy magic bitboard initialization with lazy_static, but that wasn't something I put much effort into trying to figure out. Even though all else equal I'd prefer there to be no unsafe code, this isn't very high on my priority list since the code in the unsafe blocks is stuff I understand well and am not worried about causing memory issues.

Lastly, you're definitely right that there's more to squeeze out of the move generation. In particular I'm experimenting with moving entirely to a pseudo-legal staged move generation scheme.

And thanks for the compliments! This code is definitely something I'm proud of so it's nice to hear.

matthieu commented 1 year ago

I fully understand the desire to keep it closed, no worries.

On SIMD, before going the std::simd route, I would definitely try auto-vectorization first as it'll get you at least 90% there with a fraction of the code and keep it clean. Here are a few resources you might find useful:

https://www.reidatcheson.com/matrix%20multiplication/rust/iterators/2021/02/26/gemm-iterators.html https://www.nickwilcox.com/blog/autovec/

Good luck!