[Gcblue-commits] gcb_wx/src/ai Blackboard.cpp,1.2,1.3 BlackboardInterface.cpp,1.2,1.3 Brain.cpp,1.10
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2005-12-12 02:37:10
|
Update of /cvsroot/gcblue/gcb_wx/src/ai In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16711/src/ai Modified Files: Blackboard.cpp BlackboardInterface.cpp Brain.cpp Log Message: Updates to save goals to python scenario Index: Blackboard.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/ai/Blackboard.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Blackboard.cpp 16 Feb 2005 23:13:49 -0000 1.2 --- Blackboard.cpp 12 Dec 2005 02:37:01 -0000 1.3 *************** *** 2,6 **** ** @file Blackboard.cpp */ ! /* Copyright (C) 2005 Dewitt Colclough (de...@tw...) ** All rights reserved. --- 2,6 ---- ** @file Blackboard.cpp */ ! /* Copyright (C) 2005 Dewitt Colclough (de...@gc...) ** All rights reserved. *************** *** 28,32 **** #include "ai/Blackboard.h" #include "ai/BlackboardItem.h" ! #ifdef _DEBUG --- 28,32 ---- #include "ai/Blackboard.h" #include "ai/BlackboardItem.h" ! #include "tcScenarioLogger.h" #ifdef _DEBUG *************** *** 161,164 **** --- 161,187 ---- /** + * Assumes a blackboard interface object, "BB", has been created + * on previous line. Board contents written by tasks will not be saved. + * Items with author != 0 are ignored. + * Note tasks sensitive to sim time will not be saved correctly unless + * capbility to start game with arbitrary (non-zero) sim time is added. + */ + void Blackboard::SaveToPython(scriptinterface::tcScenarioLogger& logger) + { + wxString s; + + for (std::map<std::string, BlackboardItem>::iterator iter = + content.begin(); iter != content.end(); ++iter) + { + if (iter->second.author == 0) + { + s.Printf("BB.Write('%s', '%s')", iter->first.c_str(), + iter->second.message.c_str()); + logger.AddScenarioText(s); + } + } + } + + /** * @return true if write successful, false if blocked */ Index: BlackboardInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/ai/BlackboardInterface.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BlackboardInterface.cpp 20 Feb 2005 18:20:19 -0000 1.2 --- BlackboardInterface.cpp 12 Dec 2005 02:37:01 -0000 1.3 *************** *** 31,35 **** #include <boost/python.hpp> - #ifdef _DEBUG #define new DEBUG_NEW --- 31,34 ---- *************** *** 121,125 **** } - /** * @return true if write successful, false if blocked --- 120,123 ---- Index: Brain.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/ai/Brain.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Brain.cpp 11 Dec 2005 00:34:28 -0000 1.10 --- Brain.cpp 12 Dec 2005 02:37:01 -0000 1.11 *************** *** 174,178 **** --- 174,208 ---- void Brain::SaveToPython(scriptinterface::tcScenarioLogger& logger) { + wxString s; + + std::map<std::string, Task*>::iterator iter = taskMap.begin(); + std::map<std::string, Task*>::iterator& done = taskMap.end(); + for (;iter != done; ++iter) + { + Task* task = iter->second; + wxASSERT(task); + + const std::string& taskName = task->GetTaskName(); + + s.Printf("UI.AddTask('%s', %f)", taskName.c_str(), task->GetPriority()); + logger.AddScenarioText(s); + + if (Nav* nav = dynamic_cast<Nav*>(task)) + { + const std::vector<GeoPoint>& waypoints = nav->GetWaypoints(); + for (size_t k=0; k<waypoints.size(); k++) + { + s.Printf("UI.AddNavWaypoint(%f, %f)", waypoints[k].mfLon_rad, + waypoints[k].mfLat_rad); + logger.AddScenarioText(s); + } + } + } + // write blackboard contents + logger.AddScenarioText("BB = UI.GetBlackboardInterface()"); + board.SaveToPython(logger); + + } |