def prepareForSave(): # pylint: disable=invalid-name """Called by client when the game is about to be saved, to let the Python AI know it should save any AI state information, such as plans or knowledge about the game from previous turns, in the state string so that they can be restored if the game is loaded.""" empire = fo.getEmpire() if empire is None: fatal("This client has no empire. Doing nothing to prepare for save.") return if empire.eliminated: info("This empire has been eliminated. Save info request") return info("Preparing for game save by serializing state") # serialize (convert to string) global state dictionary and send to AI client to be stored in save file import savegame_codec try: dump_string = savegame_codec.build_savegame_string() fo.setSaveStateString(dump_string) except Exception as e: error("Failed to encode the AIstate as save-state string. " "The resulting save file should be playable but the AI " "may have a different aggression. The error raised was: %s" % e, exc_info=True)
def prepareForSave(): print "Preparing for game save by serializing state" # serialize (convert to string) global state dictionary and send to AI client to be stored in save file dumpStr = pickle.dumps(foAIstate) print "foAIstate pickled to string, about to send to server" fo.setSaveStateString(dumpStr)
def prepareForSave(): # pylint: disable=invalid-name """Called by client when the game is about to be saved, to let the Python AI know it should save any AI state information, such as plans or knowledge about the game from previous turns, in the state string so that they can be restored if the game is loaded.""" empire = fo.getEmpire() if empire is None: print "This client has no empire. Doing nothing to prepare for save." return if empire.eliminated: info("This empire has been eliminated. Save info request") return info("Preparing for game save by serializing state") # serialize (convert to string) global state dictionary and send to AI client to be stored in save file try: dump_string = pickle.dumps(foAIstate) print "foAIstate pickled to string, about to send to server" fo.setSaveStateString(dump_string) except: error( "foAIstate unable to pickle save-state string; " "the save file should be playable but the AI may have a different aggression.", exc_info=True)
def prepareForSave(): # pylint: disable=invalid-name """Called by client when the game is about to be saved, to let the Python AI know it should save any AI state information, such as plans or knowledge about the game from previous turns, in the state string so that they can be restored if the game is loaded.""" print "Preparing for game save by serializing state" # serialize (convert to string) global state dictionary and send to AI client to be stored in save file dump_string = pickle.dumps(foAIstate) print "foAIstate pickled to string, about to send to server" fo.setSaveStateString(dump_string)
def prepareForSave(): # pylint: disable=invalid-name """Called by client when the game is about to be saved, to let the Python AI know it should save any AI state information, such as plans or knowledge about the game from previous turns, in the state string so that they can be restored if the game is loaded.""" empire = fo.getEmpire() if empire.eliminated: print "This empire has been eliminated. Save info request" return print "Preparing for game save by serializing state" # serialize (convert to string) global state dictionary and send to AI client to be stored in save file try: dump_string = pickle.dumps(foAIstate) print "foAIstate pickled to string, about to send to server" fo.setSaveStateString(dump_string) except: print_error("foAIstate unable to pickle save-state string; the save file should be playable but the AI may have a different aggression.", trace=True)