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

Rules for a pawn

A pawn has a unique movement too in that it moves forward, but it captures diagonally. Let's similarly override the moves_available class from within the Pawn class, as follows (see 4.04piece.py):

class Pawn(Piece):   def moves_available(self, current_position):    model = self.model    piece = self    if self.color == 'white':      initial_position, direction, enemy = 1, 1, 'black'    else:      initial_position, direction, enemy = 6, -1, 'white'    allowed_moves = []    # Moving    prohibited = model.all_occupied_positions()    start_position = get_numeric_notation(current_position.upper())    forward = start_position[0] + direction, start_position[1]    if model.get_alphanumeric_position(forward) not in prohibited:      allowed_moves.append(forward) if start_position[0] ...

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