What just happened?

We created a very simplistic API for implementing chess-like games by introducing the newGame() and move() virtual methods to the algorithm class. The former method simply sets up everything. The latter uses simple checks to determine whether a particular move is valid and whether the game has ended. We use the m_fox member variable to track the current position of the fox to be able to quickly determine whether it has any valid moves. When the game ends, the gameOver() signal is emitted and the result of the game can be obtained from the algorithm. You can use the exact same framework for implementing all chess rules.

Get Game Programming using Qt 5 Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.