Seach on github "Cosette" chess engine, that thing is lighting fast. but he seems to be used unmanaged C# for some important stuff, and he is used . net 5 with the stackalloc stuff.lithander wrote: ↑Tue Sep 14, 2021 12:07 pmI'm curious: Which C# engine *is* considered fastest? And does it really do a good job at leveraging the performance modern C# has to offer?pedrojdm2021 wrote: ↑Tue Sep 14, 2021 1:37 am Most of the fasest C# chess engine seems to do something like black magic IMO. if you want to keep a clear code without so many tricks and hacks, i'd recommend to translate the engine to C/C++ code and you will gain at least 2x performance boost for free.
That it uses black magic, tricks and hacks and ends up 2x slower than clear, readable C++ seems hard to believe to me. Also the fastest C++ engines are not exactly very readable, either... you always sacrifice some maintainability if you want to go for the best performance. In any language.
pedrojdm2021 wrote: ↑Tue Sep 14, 2021 1:37 am In my C# engine i use only pseudo legal move generation with make/undo and i am getting ~700.000 NPS in my CPU.Do I understand that right? You're both using C# but the programmer with a 0.7M NPS pseudo legal move gen explains to the programmer with a 39M nps pseudo legal move gen why C# is a really bad choice and can't be used to make a speedy engine? ...and that OP will end up smashing his head over the keyboard eventually if he doesn't migrate his engine to C++?Chessnut1071 wrote: ↑Mon Sep 13, 2021 11:32 pm So, my engine using, nodes, reaches 39,179,952 raw pseudo moves, 33,712,000 pseudo + check, and 24,277,456 pseudo + check + discovered check.
That you have been dealing with C# performance for a long time doesn't make you automatically an expert, Pedro. It seems like there's a missed learning opportunity here. And I'm not talking about OP.
about the things in C++ : bit-twiding operations, even a method call, math operations are so much faster in C++ than C#
You can write a simple benchmark,
do a simple bitboard set, some bits to it, and then do some bit-twidding operations like AND, OR , XOR
call the bitwise operations 50,000,000 times in a for loop, then mesaure performance difference between the C# console application and the C++ app the difference is quite big,
So a simpler or pretty code will be much faster than the same code in C# it maybe sound strange, but in C# even calling a empty method has a performance impact