Skip to Content
Tkinter GUI Application Development Blueprints, Second Edition - Second Edition
book

Tkinter GUI Application Development Blueprints, Second Edition - Second Edition

by Bhaskar Chaudhary
March 2018
Beginner to intermediate
422 pages
10h 33m
English
Packt Publishing
Content preview from Tkinter GUI Application Development Blueprints, Second Edition - Second Edition

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] ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Tkinter GUI Application Development Blueprints

Tkinter GUI Application Development Blueprints

Bhaskar Chaudhary

Publisher Resources

ISBN: 9781788837460Supplemental Content