O'Reilly logo

Tkinter GUI Application Development Blueprints - Second Edition by Bhaskar Chaudhary

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Movement validation of chess pieces

Before we allow chess pieces to move, we must have a record of all the possible movement options on the chessboard. At every move, we also need to check whether it is a legitimate turn for a given player and the proposed move should not cause check on the current player's king.

Now, check may occur on the king not only from a chess piece that was moved, but from any other chess piece on the chessboard as a consequence of such a movement. Thus, after every move, we need to calculate the possible moves for all the chess pieces of the opponent.

Accordingly, we will need two methods to do the following:

  • Keep a track of all the available moves for a player
  • Check whether there is check on the king

Let's add ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required