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

Keep game statistics

The pre_move_validation() method also calls another method called update_game_statistics() on successfully recording a move (see 4.06model.py):

    def update_game_statistics(self, piece, dest, start_pos, end_pos):        if piece.color == 'black':            self.fullmove_number += 1        self.halfmove_clock += 1        abbr = piece.name        if abbr == 'pawn':            abbr = ''            self.halfmove_clock = 0        if dest is None:            move_text = abbr + end_pos.lower()        else:            move_text = abbr + 'x' + end_pos.lower()            self.halfmove_clock = 0        self.history.append(move_text)

Congratulations, our chess game is now functional!

Let's complete the iteration by binding the File | New Game menu item to start a new game. Earlier, we defined the start_new_game() method. Now, it's simply a matter ...

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