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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.