A few words about the engine we're developing:
- bitboard board representation
- pre-calculated attack tables
- magic bitboards for generating sliding pieces attacks (including tutorial on how to generate magic numbers, based on idea by Tord Romstad)
- copy/make approach for making moves and taking them back
- make move function level of distinguishing between quite move and captures (for later quiescence search purposes)
- perft testing
some controversial implementations:
- global variables are used everywhere it's possible (see reasons WHY below)
- copy/make happens within a function stack (COPY -> MAKE -> COPY BACK)
A few words about the reasons behind the particular implementation (I know about OOP, encapsulation, passing pointers etc.):
- global variables are simplest to understand so viewer can focus on chess programming techniques instead of C programming best practices
- global variables save lots of source lines because no need for never ending initialization.
- current copy/make implementation is forced by the global variables and also saves some source lines
A few words about the purposes of creating this tutorial series and goals I'm targeting:
- low entry threshold (use only basic knowledge of C programming to avoid viewers getting distracted by advanced C programming techniques)
- create the simplest implementation of the complex magic bitboards based chess engine
- create as implementation agnostic as possible source code so anyone can USE THE IDEAS without any plagiarism
- create MODULAR engine, e.g. while implementing search & move ordering avoid touching code written before
- literally sacrifice almost anything for the TRUE DIDACTIC purposes
CURRENT DEVELOPMENT STATE:
We've just passed the perft test, so it's just the right time to JUMP IN for NEWCOMERS.
Assuming modular approach while writing this engine you don't need to know how move generator works in order to make use of it,
so you can kick start with actually making engine play chess via following upcoming tutorials!
NEXT STEPS:
- implement a minimal UCI interaction to debug search & evaluation in the GUI (extended UCI protocol is coming later)
- implement negamax search with alpha beta pruning (fail-hard framework)
- MVV/LVA/killer/history/PV heuristics for move ordering
- bitboard evaluation
- and much more...
SUMMARY:
Most likely my work won't be interesting to experienced chess engine developers for I'm targeting the novice auditory.
I wish I could have this like tutorials back in those days when just started chess programming.
Current series is dedicated to everyone HAVING ISSUES with READING OPEN SOURCE chess engine's code.
(I'm starting understanding it after about 5 years of chess programming)
So even if you have a very basic understanding of C programming language (or coming from high level languages like JS or Python) these tutorials are just the case for you!
Re: Bitboard CHESS ENGINE in C: YouTube series by Code Monkey King
Posted: Mon Sep 07, 2020 12:36 am
by ChessRenewal
Your Bitboard Chess Engine in C YouTube series is marvelous. I am very interested in all of the details on how a bitboard chess engine works and your series has very detailed explanations which is exactly what I want to know. I am fairly new to C programming coming from having more experience in programming in a higher level language so I appreciate your focus on the chess programming rather than the C programming. Maybe after the initial version of the bitboard engine is completed, a second version can be made with more refined C language constructs if that would result in a speedup. But already it is very nice to see that move generation is significantly faster than in your array based chess engine. Now that you have implemented move generation, I especially look forward to your further development of the code having the engine beginning to make moves and later being able to play against other engines. Thank you very much!
Re: Bitboard CHESS ENGINE in C: YouTube series by Code Monkey King
Posted: Mon Sep 07, 2020 11:01 am
by maksimKorzh
ChessRenewal wrote: ↑Mon Sep 07, 2020 12:36 am
Your Bitboard Chess Engine in C YouTube series is marvelous. I am very interested in all of the details on how a bitboard chess engine works and your series has very detailed explanations which is exactly what I want to know. I am fairly new to C programming coming from having more experience in programming in a higher level language so I appreciate your focus on the chess programming rather than the C programming. Maybe after the initial version of the bitboard engine is completed, a second version can be made with more refined C language constructs if that would result in a speedup. But already it is very nice to see that move generation is significantly faster than in your array based chess engine. Now that you have implemented move generation, I especially look forward to your further development of the code having the engine beginning to make moves and later being able to play against other engines. Thank you very much!
Hi Chess Renewal
Thanks for such an inspiring feedback!
Maybe after the initial version of the bitboard engine is completed, a second version can be made with more refined C language constructs if that would result in a speedup
The style of C programming doesn't affect performance itself. It's the matter of techniques being involved. Say we could create take_back() function to save time on copying board state, but the trick is that BBC leave a HUGE field of improvements. It tries to implement the simplest techniques possible - those that are IMO best for DIDACTIC purposes. It's kind of like a bare minimum to make engine solid)
Btw, I'm very tempted to know whether it would be as clear as BBC to you))) Please let me know! I just want to check my hypothesis on having big trouble in understanding of "best practices" code for beginners and non C programmers. Fruit reloaded is a fantastic didactic engine, probably the best one ever BUT I've started understanding it's code after years of practice)
Now that you have implemented move generation, I especially look forward to your further development of the code having the engine beginning to make moves and later being able to play against other engines.
Yup))) The most exciting topics are just about to begin) Just a few boring videos to connect engine to GUI so we could debug in GUI and then we go for search & evaluation watching how it becomes stronger and stronger!
Re: Bitboard CHESS ENGINE in C: YouTube series by Code Monkey King
Posted: Tue Sep 08, 2020 5:21 am
by ChessRenewal
Fruit reloaded looks very interesting, but in terms of the level I am presently at in understanding C language programming and chess engine algorithms your bitboard engine with commented code and extensive video discussions is much more instructive for me now and probably for a long time to come. When you come to implementing algorithms such as the transposition table and others, please provide explanations of how they work. Your video series is certainly an invaluable contribution to all who would like to understand and make a chess engine!
Re: Bitboard CHESS ENGINE in C: YouTube series by Code Monkey King
Posted: Tue Sep 08, 2020 6:40 pm
by maksimKorzh
ChessRenewal wrote: ↑Tue Sep 08, 2020 5:21 am
Fruit reloaded looks very interesting, but in terms of the level I am presently at in understanding C language programming and chess engine algorithms your bitboard engine with commented code and extensive video discussions is much more instructive for me now and probably for a long time to come. When you come to implementing algorithms such as the transposition table and others, please provide explanations of how they work. Your video series is certainly an invaluable contribution to all who would like to understand and make a chess engine!
I'll do my best! Thanks!
Re: Bitboard CHESS ENGINE in C: YouTube series by Code Monkey King
Posted: Thu Sep 24, 2020 8:36 am
by maksimKorzh
Hey what's up guys, Code Monkey King's here with a new update:
Re: Bitboard CHESS ENGINE in C: YouTube series by Code Monkey King
Posted: Thu Sep 24, 2020 12:15 pm
by maksimKorzh
mvanthoor wrote: ↑Thu Sep 24, 2020 11:28 am
BBC does not run perft(7) correctly, but perft(6) does work. I compiled the engine on Windows (under MSYS2), with the following results.
Thanks for info! I guess something wrong with node count assuming it's negative, most likely not enough bits in long integer.
Anyway thanks you for report!
Re: Bitboard CHESS ENGINE in C: YouTube series by Code Monkey King
Posted: Thu Sep 24, 2020 12:16 pm
by maksimKorzh
mvanthoor wrote: ↑Thu Sep 24, 2020 11:28 am
BBC does not run perft(7) correctly, but perft(6) does work. I compiled the engine on Windows (under MSYS2), with the following results.
Re: Bitboard CHESS ENGINE in C: YouTube series by Code Monkey King
Posted: Thu Sep 24, 2020 12:28 pm
by mvanthoor
maksimKorzh wrote: ↑Thu Sep 24, 2020 12:16 pm
But how do you like the games??
The games are fine Consistently beating TSCP is one of the goals of most engine developers when they are just starting out. I hope the two games you've posted are not 'accidents', and that you can actually win a 100 game match against TSCP. If so, you can estimate your engine's approximate strength. (TSCP is rated around CCRL 1700). You should now set up a gauntlet tournament to see where your engine falls. Don't just try to improve your results against TSCP, or you might end up tuning your engine to explicitly defeat TSCP and perform worse against other engines.