Devlog 0x9 - Refactoring
Devlog 0x9. Over the last 24 hours, I've done a lot of learning and a lot of refactoring to Kirin. Here are the changes I have made.
1,000 Lines in 24 Hours
After a suggestion from Hejsil to use a packed struct as opposed to a u32 in my engine, I had a realization: Why am I rewriting this engine in Zig if I am just going to treat Zig like it's C? There are many benefits that Zig offers that I wasn't taking advantage of, as well as the verbosity of the codebase going up exponentially with each addition.
So what did I do? Binge code for the last ~24 hours. Here's a list of what's changed(basically everything):
- Ensuring safety of bitwise operations using assert
- New bitboard data structure
- New move data structure. Implemented as a 24 bit packed struct.
- Complete refactor of attacks.zig and movegen.zig, using these data structures.
- Use compile-time constants for magic numbers & lookup tables
- Leverage Zig's comptime features for better performance
Sorry for the short devlog, but I'm tired! Tomorrow I will try and talk more about various improvements, and continue to show development progress.
Check out the commit on Github.
What's next
- Implement move generation for Queens
- Add move validation and legal move filtering
- Implement basic search algorithm (negamax)
- Add position evaluation
- Implement basic UCI protocol support
Thanks for reading, see you tomorrow :)