~webdrake/minga/minga

« back to all changes in this revision

Viewing changes to minga/game.hpp

  • Committer: Joseph Rushton Wakeling
  • Date: 2009-09-27 13:08:32 UTC
  • Revision ID: joe@webdrake.net-20090927130832-bla3kox35td6glsj
Extended game export functions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
366
366
         * Exports generic variables, then calls _export_game_start() to get
367
367
         * subclass-specific details.  N.B. agents are not exported.
368
368
         */
369
 
        string export_game_start()
 
369
        string export_game_start(bool export_game_type=true)
370
370
        {
371
371
                stringstream export_data;
372
372
 
373
 
                export_data << varexport(type(),"game_type");
 
373
                if(export_game_type)
 
374
                        export_data << varexport(type(),"game_type");
374
375
 
375
376
                vector<history_t> starting_history;
376
377
                starting_history.assign(_history.begin(),_history.begin()+lag()+turns_at_start());
377
 
                if(!starting_history.empty())
378
 
                        export_data << varexport(starting_history,"starting_history");
 
378
                export_data << varexport(starting_history,"starting_history");
379
379
 
380
380
                vector<collective_action_t> starting_collective_action;
381
381
                starting_collective_action.assign(_collective_action.begin(),_collective_action.begin()+turns_at_start());
382
 
                if(!starting_collective_action.empty())
383
 
                        export_data << varexport(starting_collective_action,"starting_collective_action");
 
382
                export_data << varexport(starting_collective_action,"starting_collective_action");
384
383
 
385
384
                export_data << _export_game_start();
386
385
 
395
394
         * Exports generic variables, then calls _export_game_play() to get
396
395
         * subclass-specific details.  N.B. agents are not exported.
397
396
         */
398
 
        string export_game_play()
 
397
        string export_game_play(bool export_game_type=true)
399
398
        {
400
399
                stringstream export_data;
401
400
 
402
 
                export_data << varexport(type(),"game_type");
 
401
                if(export_game_type)
 
402
                        export_data << varexport(type(),"game_type");
403
403
 
404
404
                vector<history_t> history_export;
405
405
                unsigned int n = _history.size()-(_collective_action.size()+lag());
417
417
                return export_data.str();
418
418
        }
419
419
 
 
420
        string export_game_full()
 
421
        {
 
422
                return export_game_start().append(export_game_play(false));
 
423
        }
 
424
 
420
425
        /**
421
426
         * @brief Export all the agents.
422
427
         *   @return vector of containing agents' internal states in Minga's