Updated to use instanceof statements to determine the piece class type
Merging the latest changes with the Rules class where the instanceof statements have been used to determine the piece class type.