The process of teaching MATT how to play Chess

The assignment

As the Adapta Robotics team is an avid supporter of learning, and wanting to promote it in any way, shape or form, we decided to share with you the experience of one of our interns in the Students’ Program as he tackles the challenge of making MATT play chess. Let’s hear them out:

The planning process

First step in getting familiarized with MATT was to learn its framework. The process was surprisingly easy and, after one week of getting accustomed to the testing robot, I’ve got the task of teaching MATT how to play chess.

My first though was to search for an online digital chess board but scrolling through websites proved to be a first challenge. For this reason, I decided that the best approach would be to use an app, Chess.com. The choice was not random. Having analyzed multiple apps, I noticed that Chess.com had the option of changing the colors of the board. This feature helped me underline the method I used to complete the task: scanning the board not for the piece that was moved, but by the colored squares it left on the board from its initial position and its move destination (the ‘footprints’ of executed moves).

After some planning, I found it useful to integrate the Stockfish chess engine in my code and use it as storage for the date referring to chess pieces’ positions and the state of the game. The next step was to design an algorithm that detected the opponent’s move. As I mentioned earlier, the option of changing the board’s theme was extremely useful since it allowed me to choose the color that was easiest to detect in the given environment and to create a function that was searching for that precise color. Finishing the color detection stage and beginning the calibration and debugging process, I realized that the hard part just began. After every modification, to observe new errors or miscalibrations I started watching one, two or more matches, sometimes as long as 30 minutes each; a very time consuming but necessary operation that was essential in perfecting the way I was solving the given task.

Second iteration, improvements, and challenges

After the first iteration of the code, MATT was able to play only with the white pieces and only with Chess.com bots. Wanting to make MATT game universal, I perfected a new version of the program with a cleaner structure, able to play with any chess piece color and that had the feature to set up the position of the board, making it possible to play on any mode. Furthermore, I upgraded the board scanning algorithm that detected the blue squares (the ‘footprints’ of executed moves). During this stage, an issue that I’ve met was the tap response time of the phone’s touchscreen. To solve it, I replaced MATT’s simple taps with short holds of 0.2 seconds.

After finishing the remaining touchups, I rewrote the board scanning algorithm, which consequently generated faster results, and I started the final tests of the program to find leftover bugs. In the end, the program acted as an intermediate for MATT robot and the Stockfish chess engine, it’s job being to scan the table, to check if the opponent’s move is correct, to pass the information to the engine and to maneuver MATT’s arm in order to move a chess piece.

Conclusion

To sum it up, I can say it was a fascinating experience and a practical way to apply some of the knowledge I’ve gained during the training sessions. During the task, I found working with MATT to be very pleasant due to its ability to execute individual simple tasks and being easy to program, that combined led to easiness in carrying out more complex operations.

You can watch a full MATT played match on our Youtube channel.

VIEW MORE Articles >

DO YOU WANT TO KNOW MORE?

SEND A MESSAGE









    Contact

    Skanska Green Court, 3rd floor, Building B, Bucharest, Romania

    Follow us

    Subscribe to our newsletter