[Gcblue-commits] gcb_wx/src/ai Brain.cpp,1.5,1.6 ScriptedTaskInterface.cpp,1.2,1.3
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2005-03-02 22:29:27
|
Update of /cvsroot/gcblue/gcb_wx/src/ai In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15614/src/ai Modified Files: Brain.cpp ScriptedTaskInterface.cpp Log Message: Better sensor ageout behavior, more ai work, misc cleanup Index: ScriptedTaskInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/ai/ScriptedTaskInterface.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ScriptedTaskInterface.cpp 24 Feb 2005 22:19:15 -0000 1.2 --- ScriptedTaskInterface.cpp 2 Mar 2005 22:28:42 -0000 1.3 *************** *** 123,126 **** --- 123,128 ---- { wxASSERT(task); + + if (interval < 0.1f) interval = 0.1f; // 10 Hz maximum task->SetUpdateInterval(interval); } Index: Brain.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/ai/Brain.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Brain.cpp 24 Feb 2005 22:19:15 -0000 1.5 --- Brain.cpp 2 Mar 2005 22:28:41 -0000 1.6 *************** *** 27,30 **** --- 27,31 ---- #include "ai/Brain.h" + #include "ai/BlackboardInterface.h" #include "ai/Task.h" #include "ai/Nav.h" *************** *** 52,55 **** --- 53,64 ---- /** + * gets a low priority, anonymous interface to board + */ + BlackboardInterface Brain::GetBlackboardInterface() + { + return BlackboardInterface(&board, 0, 0.0); + } + + /** * @return pointer to Nav task or 0 if none exists */ *************** *** 161,164 **** --- 170,189 ---- /** + * Removes all tasks. Cannot be called in the middle of an + * update (i.e. can't be called by task) + */ + void Brain::RemoveAllTasks() + { + if (updating) return; + + std::map<std::string, Task*>::iterator iter = taskMap.begin(); + while (iter != taskMap.end()) + { + delete iter->second; + taskMap.erase(iter++); + } + } + + /** * Removes tasks in removeList. This allows a task to safely delete itself. */ *************** *** 212,215 **** --- 237,242 ---- RemovePending(); + updating = true; + // iterate through task map and update tasks std::map<std::string, Task*>::iterator iter = taskMap.begin(); *************** *** 223,226 **** --- 250,255 ---- lastUpdateTime = t; + + updating = false; } *************** *** 228,233 **** : platform(platform_), updateInterval(0.125f), ! nextId(0), ! target(-1) { wxASSERT(platform); --- 257,263 ---- : platform(platform_), updateInterval(0.125f), ! nextId(1), ! target(-1), ! updating(false) { wxASSERT(platform); |