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

Tracking all available moves

The code needed to keep track of all the available moves for a player is as follows:

def get_all_available_moves(self, color):  result = []  for position in self.keys():    piece = self.get_piece_at(position)    if piece and piece.color == color:       moves = piece.moves_available(position)       if moves:         result.extend(moves)  return result

The description of the code is as follows:

  • We have already coded the moves_available method in the previous iteration
  • The preceding method simply iterates through every item in the dictionary and appends the moves_available result for every chess piece of a given color in a list named result
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