saving game state

Help
Brian King
2009-06-25
2013-04-15
  • Brian King
    Brian King
    2009-06-25

    There is an option "-savefile : file to save state to" in the GameStateModule, but I don't see how to trigger saving the state.  In Server.C there is

        if (game->get_save_req()) {
          ostringstream oss;
          game->save(oss);

    and in Game.C there is

    void Game::preprocess_actions(Vector<string> &actions)
    {
      FORALL (actions, it) {
        const string &s = *it;
        if (s.empty()) continue;
        ByteStream bs(s);
        sint4 id = bs.read_b_int4();
        if (id == -1) save_req = true;
      }
    }

    but I don't see how to use these to make the server save the game.  Setting a filename for savefile on the command line doesn't seem to result in anything. Anyone know how to save state?  Thanks.

     
    • Tim
      Tim
      2009-06-26

      Technically the clients can send a request, but I don't think that saving state was ever fully implemented/debugged.  There should be some client-side code lying around for this (possibly commented out or in the interface scripts).

      I don't recall offhand what part of the save code is missing (probably persistence of object ids in pending actions, although this might be a non-issue now).  Most of the code is actually in place, but there was never a pressing need to get it finished.

       
    • Brian King
      Brian King
      2009-06-29

      Thanks.  I will try writing some code to have the server log state.  I just needed to check if this was already implemented.

       
      • Tim
        Tim
        2009-06-29

        You can certainly save/load replay files (action logs, essentially).  If the server is started with the same seed and initial setup then the resulting state is identical.  Client actions are accepted as normal once the log runs out.

        Are you trying to do something in particular?

         
    • Brian King
      Brian King
      2009-06-29

      I want to analyze the state sequence offline to see what kind of feature extraction would be useful for an AI.  Another thing I could try would be to save the client's view of the state rather than the server's.

      Saving state fails in ScriptObj::save() where there is an error macro

        ERR("need PlayerInfo data here");

      so I guess saving was disabled for some reason.  Commenting out the macro leads to a seg fault.

       
      • Tim
        Tim
        2009-06-29

        Well, not disabled, just not implemented.  Hence the segfault.

        I'd suggest just storing the replay log.  During the game or for analysis you can always use the synchro flag to step through at whatever pace you want.