Code to save and restore state of a chess game