Console #191 -- Interview with Bernhard of ACID Chess - Chess computer for nerds, by nerds
Featuring Harlequin, Maestro, and ACID Chess
🤝 Sponsor
This space is reserved for sponsors that support us to keep the newsletter going! Want to support Console? Send us a note at osh@codesee.io
🏗️ Projects
Browse through open source projects on OpenSourceHub.io, add your project to get more exposure and connect with other maintainers and contributors!
Harlequin
The SQL IDE for your terminal.
language: Python stars: 1240
repo: github.com/tconbeer/harlequin
site: harlequin.sh
Maestro
Maestro is a lightweight Unix-like kernel written in Rust. The goal is to provide a lightweight operating system able to use the safety features of the Rust language to be reliable.
language: Rust stars: 2002
repo: github.com/llenotre/maestro
site: blog.lenot.re
ACID Chess
ACID Chess is a chess computer written in Python, which can be used with any board. By filming the board, the contour of the board is recognized, and the positions of the individual pieces can be determined.
language: Python stars: 12
repo: github.com/ierror/acid-chess
Join thousands of other open-source enthusiasts and developers in the Open Source Hub Discord server to continue the discussion on the projects in this week's email!
🎙️ Interview With Bernhard of ACID Chess - Play Chess by filming the board
Hey Bernhard! Thanks for joining us! Let us start with your background.
I live in Munich and work for a company that manufactures computer-aided dental restorations. Previously I worked in a consultancy where we supported our customers in collecting and analyzing large amounts of data.
My father has always had computers (even in the pre-internet era). He showed me a few things in Basic and gave me one of his books. That's how I got into programming.
My favorite programming languages are Python, sometimes Perl and JavaScript - I also like C# for GUI projects at work.
What’s your most controversial programming opinion?
The way we develop software in the corporate world today often leads to unnecessarily complex systems. Clean coding, object-oriented programming or other "sacred" patterns often lead us to focus more on ourselves and our software than on the actual problem. Don't get me wrong, these patterns are absolutely legitimate. I often wish that people would think about how to structure code in such a way that it is easy to read and doesn't simply follow a pattern.
What is your favorite software tool?
Is “Linux” a valid answer? :)
Why was ACID Chess started?
I've enjoyed playing a game of chess over the board from time to time for a few years now. When discussing the games and trying to understand why a game has taken such and such a turn, beginners are often overwhelmed. At some point, I came up with the idea of simply recording the game with the camera and recognising the moves using image recognition. The sequence of moves can then be fed into an engine for analysis. Using this as a basis to build a chess computer was somehow obvious.
How does ACID Chess work?
A camera films the chessboard, which is analyzed on the basis of individual frames.
In the first step, the board contour is determined, the board is cutted, transformed and cut into 64 squares. The squares are then classified to determine the game state.
1. Recognising the board contour: In order to prevent unnecessary dirt from interfering with the recognition of the individual board squares, the outline of the board is recognised first. To do this, I trained a neural network - the "Board Segmentation Model" - the border of the board is extracted from the outline of the board using openCV. The four corner points are then determined from this line. With the help of the 4 points, the board can be cut out and a "birds eye view" of the board can be created with a 4-point perspective transformation.
2. Cutting the board into 64 squares: From the "birds eye view" image of the board, OpenCV algorithms (medianBlur, auto_canny, HoughLinesP, ...) are then used to adaptively extract nine horizontal and nine vertical lines. Once these lines have been found, the image can be cut into 64 squares.
3. The classification of the squares: As I do not have enough training data available, I have decided not to recognise the individual figures, but to train only three classes for the "Square Classification Models":
1. is the square occupied by a black piece?
2. is the square occupied by a white piece?
3. is the square free?
Assuming that the board is in the starting position, all the necessary information is available to determine the orientation of the board and to recognise the moves.
Where did the name for ACID Chess come from?
While experimenting with OpenCV and the chessboard images, I created some crazy visualizations. A mate said "it looks like a chessboard on drugs" - that's how it got its name.
What is the most challenging problem that’s been solved in ACID Chess, so far
The recognition of the board contour and the recognition of the horizontal / vertical lines to intersect the square.https://acid-chess.readthedocs.io/en/latest/dev/neural_networks.html
What was the most surprising thing you learned while working on ACID Chess?
Previously I only had theoretical knowledge of neural networks. The level that PyTorch and other frameworks have reached today makes it possible to extend existing networks and train your own network without having to study documentation for months.
What are you most proud of?
The whole chain, starting with the crawling of board images, data cleaning, classification, training of the models, and the GUI part of the application was written completely by myself.
How do you balance your work on side projects like these with your day job and other responsibilities?
With my day job, I occasionally have to work late in the evening or at the weekend, but generally I have very regular working hours. In summer, I cycle long distances a lot, but in winter I miss that. These side projects are a good balance at winter times.
Where do you see the project heading next?
The chess computer already works very well for me and a few friends. If you're not on Apple hardware, there are still a few things to improve. I also hope to receive better training data in the future, which I can use to significantly improve the stability of the board recognition and the square classification.
Are there any other projects besides ACID Chess that you’re working on?
I'm working with a friend on a software to manage bike tours. However, this has not yet reached a release-ready status 🙂
Where do you see software development heading next?
AI will simplify and improve many things in software development, such as vulnerability detection, code reviews and so on. Whether this leads to better products, depends, as is so often the case, on how we use the tools.
Where do you see open-source heading next?
When I look at open source projects such as Linux, FreeBSD or the Django framework, for example, I am very confident that we will continue to see good open source software. Monetising open source software will continue to be difficult for "small developers". I have no idea how this could be improved, but I hope that better ways will be found in the future.
Do you have any suggestions for someone trying to make their first contribution to an open-source project?
Read the contribution guidelines and simply start with it. Even if you have no idea about the big picture, you can often get involved in projects through smaller issues. In my experience, the other developers are usually very helpful and are always happy to get involved.
Want to join the conversation about one of the projects featured this week? Drop a comment, or see what others are saying!
Interested in sponsoring the newsletter or know of any cool projects or interesting developers you want us to interview? Reach out at osh@codesee.io or mention us @ConsoleWeekly!