AI Chess

A Python-based chess game with an AI opponent using Minimax and Alpha-Beta pruning.



AI Chess was developed during my first year of studies as part of a school project focused on artificial intelligence. The assignment was flexible in terms of topic, with the only requirement being the implementation of some form of AI. I chose to create a chess engine because I’ve always enjoyed playing chess, and the challenge of building an AI capable of strategic decision-making seemed both exciting and meaningful. This project allowed me to combine my interest in the game with my curiosity about algorithmic thinking and game development.


The first step in this project was building a fully playable chess game. While I could have used an existing chess application, creating my own from scratch proved more effective in the long run. It gave me full control over the game logic and made it easier to integrate the AI engine, as I could freely adjust both the engine and the game to work seamlessly together. One of the more challenging aspects was implementing complex rules such as castling, which involves moving two pieces in a single turn and requires careful handling of game state and move validation.


The next and most important part of this project was developing the AI opponent. I implemented a Minimax algorithm with Alpha-Beta pruning to allow the AI to evaluate and choose the optimal move by simulating potential future game states. Alpha-Beta pruning significantly improved perfomance by eliminating branches that didn't need to be explored. The evaluation function considered factors like material value, control of the board, and piece mobility.


This project was developed using Python and the Pygame library. I chose Python because it’s the language I’m most comfortable with, having used it for around five years. I applied object-oriented programming principles, including inheritance, by creating a base class that implemented the core game rules. From this base, I extended the functionality to build a full graphical game. Pygame enabled me to design an interactive 2D interface that brought the game to life. I hadn't used Pygame before, but it was simple to pick up.


View project