Rules for the king, queen, rooks, and bishops

Let's first take a look at simple cases of orthogonally and diagonally moving chess pieces, which are the king, queen, rooks, and bishops. We need somehow to figure out a way to change the position of these chess pieces by using a mathematical rule.

The following diagram shows what it takes to move a chess piece from its current position (say x, y) both orthogonally and diagonally:

If you look at the preceding diagram, x represents the column number and y represents the row number. It is clear that we can represent the orthogonal movements by adding to the current position the items from the tuples ...

Get Tkinter GUI Application Development Blueprints - 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.