DEV Community

Nicholas
Nicholas

Posted on

My first post

Hey everyone, it’s my first post here ;)

Today I want to show you the project I’m currently working on. It’s Chess Project X (available as chess-project on GitHub). The development is divided into two main milestones.

Milestone 1: The Matrix Engine & UI

The first step was creating a basic chess engine from scratch along with a graphical interface. I built the initial core using matrix logic in pure Python and used the Pygame library for the UI. It includes all the neat features I personally enjoy on Chess.com: analysis arrows, highlighted squares, visual move hints, and even the native sound effects.
For the AI at this stage, I implemented a classic Minimax algorithm with Alpha-Beta pruning running at a maximum depth of 4.
Check video of gameplay on X:

Milestone 2: Transitioning to Bitboards & RL

The ultimate goal is to implement a Reinforcement Learning (RL) agent. Doing this on top of a matrix-based engine would be heavily bottlenecked by performance, so I decided to rewrite the entire engine using bitboards.
Current state of the rewrite:

  • Implemented a new Board class.
  • Wrote basic bitwise utility functions (set_bit, get_bit, pop_bit).
  • Generated pre-computed attack masks for every piece type. For the last two days, I’ve been heavily focused on the move validation logic. There are two ways to find legal moves:
  • The Matrix Way: Execute make_move, check if the king is under attack, and then undo_move. It's easy to code but much slower.
  • The Bitboard Way: Generate all possible pin and check masks via bitwise operations. It's significantly harder to implement, but the performance payoff is massive. Right now, I've finished the logic for the king and knights. Next up: rooks, bishops, queens, and pawns. Once done, I’ll hook it up to the Pygame UI, run tests, and finally start training the RL model!

I hope you found this breakdown interesting! If you have any questions, tech suggestions, or ideas about bitboards, feel free to drop them in the comments below. See you in the next update!



#python #chess #reinforcementlearning #bitboards

Top comments (0)