当前位置: 首页>>代码示例>>C++>>正文


C++ Agent::beliefs方法代码示例

本文整理汇总了C++中Agent::beliefs方法的典型用法代码示例。如果您正苦于以下问题:C++ Agent::beliefs方法的具体用法?C++ Agent::beliefs怎么用?C++ Agent::beliefs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Agent的用法示例。


在下文中一共展示了Agent::beliefs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getBeliefs

/*
*   Return the list of beliefs of an agent in an OPC given
*   bInput format : getBeliefs real/mental  agent
*/
Bottle opcManager::getBeliefs(Bottle bInput)
{
    Bottle bOutput;
    if (bInput.size() != 3)
    {
        cout << "Error in opcManager::getBeliefs | wrong size of input" << endl;
        bOutput.addString("Error in opcManager::getBeliefs | wrong size of input");
        return bOutput;
    }

    if (bInput.get(1).toString() != "real" && bInput.get(1).toString() != "mental")
    {
        cout << "Error in opcManager::getBeliefs | unknown OPC (real/mental)" << endl;
        bOutput.addString("Error in opcManager::getBeliefs | unknown OPC (real/mental)");
        return bOutput;
    }

    Agent *agent;
    if (bInput.get(1).toString() == "real")
    {
        agent = dynamic_cast<Agent*>(realOPC->getEntity(bInput.get(2).toString().c_str()));
    }
    else
    {
        agent = dynamic_cast<Agent*>(mentalOPC->getEntity(bInput.get(2).toString().c_str()));
    }

    list<Relation> lRelation = agent->beliefs();

    cout << endl << agent->name() << " has the following beliefs in the " << bInput.get(1).toString() << " OPC (" << lRelation.size() << ") : " << endl;

    for (list<Relation>::iterator it_R = lRelation.begin(); it_R != lRelation.end(); it_R++)
    {
        Bottle bTemp = it_R->asLightBottle();
        cout << bTemp.toString() << endl;
        bOutput.addList() = bTemp;
    }

    cout << endl;

    return bOutput;
}
开发者ID:GunnyPong,项目名称:wysiwyd,代码行数:46,代码来源:opcManager.cpp

示例2: updateBelief

Bottle opcManager::updateBelief(string sOPCname)
{
    cout << "Updating the beliefs in OPC ... ";

    Bottle bOutput;
    // Create the beliefs
    bool bReal = sOPCname == s_realOPC;

    if (bReal)
    {
        realOPC->checkout();
        realOPC->update();
    }
    else
    {
        mentalOPC->checkout();
        mentalOPC->update();
    }

    Bottle bMessenger;
    bMessenger.addString("updateObjectLocation");
    bMessenger.addString(sOPCname.c_str());
    portToAbmReasoning.write(bMessenger, bMessenger);

    // Set the Bottles for queryOPC to the 

    Bottle isRtobject, conditionAgent, conditionRTO;
    isRtobject.addString(EFAA_OPC_ENTITY_TAG);
    isRtobject.addString("==");
    isRtobject.addString(EFAA_OPC_ENTITY_RTOBJECT);

    Bottle isAgent;
    isAgent.addString(EFAA_OPC_ENTITY_TAG);
    isAgent.addString("==");
    isAgent.addString(EFAA_OPC_ENTITY_AGENT);

    Bottle isPresent;
    isPresent.addString(EFAA_OPC_OBJECT_PRESENT_TAG);
    isPresent.addString("==");
    isPresent.addInt(1);

    conditionAgent.addList() = isAgent;
    conditionAgent.addString("&&");
    conditionAgent.addList() = isPresent;

    conditionRTO.addList() = isRtobject;
    conditionRTO.addString("&&");
    conditionRTO.addList() = isPresent;


    list<Entity*> PresentEntities;
    list<Relation> listRelations;


    // Create the Relations
    Adjective* present;
    Action* is;
    //Action* isDoing;

    if (bReal)
    {
        PresentEntities = realOPC->Entities(conditionAgent);
        list<Entity*> tmp = realOPC->Entities(conditionRTO);
        PresentEntities.splice(PresentEntities.end(), tmp);
        listRelations = realOPC->getRelations();
        present = realOPC->addOrRetrieveEntity<Adjective>("isPresent");
        present->m_quality = "presence";
        is = realOPC->addOrRetrieveEntity<Action>("is");
        //isDoing = realOPC->addOrRetrieveEntity<Action>("isDoing");
    }
    else
    {
        PresentEntities = mentalOPC->Entities(conditionAgent);
        list<Entity*> tmp = mentalOPC->Entities(conditionRTO);
        PresentEntities.splice(PresentEntities.end(), tmp);
        listRelations = mentalOPC->getRelations();
        present = mentalOPC->addOrRetrieveEntity<Adjective>("isPresent");
        present->m_quality = "presence";
        is = mentalOPC->addOrRetrieveEntity<Action>("is");
        //isDoing = mentalOPC->addOrRetrieveEntity<Action>("isDoing");
    }

    for (list<Entity*>::iterator it_E = PresentEntities.begin(); it_E != PresentEntities.end(); it_E++)
    {
        if (bReal)
            realOPC->addRelation(*it_E, is, present, time_relation);
        else
            mentalOPC->addRelation(*it_E, is, present, time_relation);
        listRelations.push_back(Relation(*it_E, is, present));
    }

    // get the Agents present

    vector<Relation> vRelToAdd,
        vRelToRemove;

    list<Entity*> PresentAgents;
    if (bReal)
        PresentAgents = (realOPC->Entities(conditionAgent));
    else
//.........这里部分代码省略.........
开发者ID:GunnyPong,项目名称:wysiwyd,代码行数:101,代码来源:opcManager.cpp


注:本文中的Agent::beliefs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。