[Gcblue-commits] gcb_wx/src/ai Blackboard.cpp,NONE,1.1 BlackboardItem.cpp,NONE,1.1 Brain.cpp,NONE,1.
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2005-02-04 18:50:45
|
Update of /cvsroot/gcblue/gcb_wx/src/ai In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24940/src/ai Added Files: Blackboard.cpp BlackboardItem.cpp Brain.cpp Task.cpp Log Message: Ground SAM related updates --- NEW FILE: Blackboard.cpp --- /** ** @file Blackboard.cpp */ /* Copyright (C) 2005 Dewitt Colclough (de...@tw...) ** All rights reserved. ** This file is part of the Global Conflict Blue (GCB) program. ** GCB is free software; you can redistribute it and/or modify ** it under the terms of version 2 of the GNU General Public License as ** published by the Free Software Foundation. ** GCB is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** You should have received a copy of the GNU General Public License ** along with GCB; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "stdwx.h" #ifndef WX_PRECOMP #include "wx/wx.h" #endif #include "ai/Blackboard.h" #include "ai/BlackboardItem.h" #ifdef _DEBUG #define new DEBUG_NEW #endif using namespace ai; void Blackboard::EraseAll() { content.clear(); } void Blackboard::Erase(const std::string& key, double priority) { std::map<std::string, BlackboardItem>::iterator iter = content.find(key); if (iter != content.end()) { if (iter->second.priority <= priority) { content.erase(iter); } } } bool Blackboard::KeyExists(const std::string& key) const { std::map<std::string, BlackboardItem>::const_iterator iter = content.find(key); return (iter != content.end()); } BlackboardItem Blackboard::Read(const std::string& key) { std::map<std::string, BlackboardItem>::const_iterator iter = content.find(key); if (iter == content.end()) { return BlackboardItem(); } else { return BlackboardItem(iter->second); } } double Blackboard::ReadPriority(const std::string& key) { std::map<std::string, BlackboardItem>::const_iterator iter = content.find(key); if (iter == content.end()) { return -1.0; } else { return iter->second.priority; } } void Blackboard::Write(const std::string& key, const BlackboardItem& item) { std::map<std::string, BlackboardItem>::iterator iter = content.find(key); // if the item already exists check that the author matches or priority is greater to write if (iter != content.end()) { if ((iter->second.priority > item.priority) && (iter->second.author != item.author)) { return; } iter->second = item; } else { content[key] = item; } } void Blackboard::Write(const std::string& key, long author, double priority, const std::string& message) { std::map<std::string, BlackboardItem>::iterator iter = content.find(key); // if the item already exists check that the author matches or priority is greater to write if (iter != content.end()) { if ((iter->second.priority > priority) && (iter->second.author != author)) { return; } iter->second.author = author; iter->second.priority = priority; iter->second.message = message; } else { content[key] = BlackboardItem(author, priority, message); } } Blackboard::Blackboard() { } Blackboard::~Blackboard() { } --- NEW FILE: Task.cpp --- /** ** @file Task.cpp */ /* Copyright (C) 2005 Dewitt Colclough (de...@tw...) ** All rights reserved. ** This file is part of the Global Conflict Blue (GCB) program. ** GCB is free software; you can redistribute it and/or modify ** it under the terms of version 2 of the GNU General Public License as ** published by the Free Software Foundation. ** GCB is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** You should have received a copy of the GNU General Public License ** along with GCB; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "stdwx.h" #ifndef WX_PRECOMP #include "wx/wx.h" #endif #include "ai/Task.h" #ifdef _DEBUG #define new DEBUG_NEW #endif using namespace ai; void Task::SetBoard(Blackboard* bb) { commBoard = bb; } void Task::SetId(long id_) { } void Task::SetPriority(double priority_) { } Task::Task(Blackboard* bb, long id_, double priority_) : commBoard(bb), id(id_), priority(priority_) { } Task::Task() : commBoard(0), id(-1), priority(0) { } Task::~Task() { } --- NEW FILE: Brain.cpp --- /** ** @file Brain.cpp */ /* Copyright (C) 2005 Dewitt Colclough (de...@tw...) ** All rights reserved. ** This file is part of the Global Conflict Blue (GCB) program. ** GCB is free software; you can redistribute it and/or modify ** it under the terms of version 2 of the GNU General Public License as ** published by the Free Software Foundation. ** GCB is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** You should have received a copy of the GNU General Public License ** along with GCB; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "stdwx.h" #ifndef WX_PRECOMP #include "wx/wx.h" #endif #include "ai/Brain.h" #ifdef _DEBUG #define new DEBUG_NEW #endif using namespace ai; Brain::Brain() { } Brain::~Brain() { } --- NEW FILE: BlackboardItem.cpp --- /** ** @file BlackboardItem.cpp */ /* Copyright (C) 2005 Dewitt Colclough (de...@tw...) ** All rights reserved. ** This file is part of the Global Conflict Blue (GCB) program. ** GCB is free software; you can redistribute it and/or modify ** it under the terms of version 2 of the GNU General Public License as ** published by the Free Software Foundation. ** GCB is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** You should have received a copy of the GNU General Public License ** along with GCB; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "stdwx.h" #ifndef WX_PRECOMP #include "wx/wx.h" #endif #include "ai/BlackboardItem.h" #ifdef _DEBUG #define new DEBUG_NEW #endif using namespace ai; bool BlackboardItem::Valid() const { return author != -1; } BlackboardItem& BlackboardItem::operator=(const BlackboardItem& rhs) { author = rhs.author; priority = rhs.priority; message = rhs.message; return *this; } BlackboardItem::BlackboardItem(const BlackboardItem& src) : author(src.author), priority(src.priority), message(src.message) { } BlackboardItem::BlackboardItem(long author_, double priority_, const std::string& message_) : author(author_), priority(priority_), message(message_) { } BlackboardItem::BlackboardItem() : author(-1), priority(-1.0), message("") { } BlackboardItem::~BlackboardItem() { } |