def play_billiards(score=[0,0], moves=[], reject_illegitimate_move(move): if move not in legit_moves: print("move rejected, restore to the beginning"); return true, earlier_solution(): print("restoring scores to earlier counts"); return score, main(): while not winner(score): move = get_move(); if not reject_illegitimate_move(move): score = update_score(score, move); else: earlier_solution(); print("enjoy your game responsibly and ensure fair play!");