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

Check whether a move will cause check on the King

Though a major part of the validation check done in the preceding lines is simple, one of the validation steps needs to check whether a movement will cause the king to be in check. This is a tricky situation. We can only find this out after we have made the actual move. However, we cannot allow that movement to happen on the chessboard.

To do this, the pre_move_validation method calls a method named will_move_cause_check, which creates a copy of the Model class. Then, it performs a move on the new temporary copy to check whether it does cause a king to be in check. The code for this is as follows (4.06model.py):

def will_move_cause_check(self, start_position, end_position): tmp = deepcopy(self) ...
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