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


C++ AgentNodeTest::btsetcurrent方法代码示例

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


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

示例1:

LOAD_TEST(btunittest, selector_probability_ut_2)
{
	const char* tree = "node_test/selector_probability_ut_2";

	behaviac::Profiler::CreateInstance();
	behaviac::Config::SetSocketing(false);
	behaviac::Config::SetLogging(false);

	//behaviac::Agent::Register<AgentNodeTest>();
	registerAllTypes();
	AgentNodeTest* myTestAgent = AgentNodeTest::DynamicCast(behaviac::Agent::Create<AgentNodeTest>());
	behaviac::Agent::SetIdMask(1);
	myTestAgent->SetIdFlag(1);
	myTestAgent->btload(tree);
	myTestAgent->btsetcurrent(tree);
	myTestAgent->resetProperties();

	int loopCount = 10000;

	while (loopCount > 0)
	{
		myTestAgent->btexec();
		CHECK_EQUAL(-1, myTestAgent->testVar_0);
		--loopCount;
	}

	unregisterAllTypes();
	BEHAVIAC_DELETE(myTestAgent);
	//behaviac::Agent::UnRegister<AgentNodeTest>();

	behaviac::Profiler::DestroyInstance();
}
开发者ID:Evilcoolkings,项目名称:behaviac,代码行数:32,代码来源:NodeUnitTest.cpp

示例2: registerAllTypes

//< Wait For Frames Tests
LOAD_TEST(btunittest, action_waitframes_ut_0)
{
    behaviac::Profiler::CreateInstance();
    behaviac::Config::SetSocketing(false);
    behaviac::Config::SetLogging(false);

    //behaviac::Agent::Register<AgentNodeTest>();
    registerAllTypes();
    AgentNodeTest* myTestAgent = AgentNodeTest::DynamicCast(behaviac::Agent::Create<AgentNodeTest>());
    behaviac::Agent::SetIdMask(1);
    myTestAgent->SetIdFlag(1);
    myTestAgent->btload("node_test/action_waitframes_ut_0");
    myTestAgent->btsetcurrent("node_test/action_waitframes_ut_0");
    myTestAgent->resetProperties();

    int loopCount = 0;

	behaviac::Workspace::GetInstance()->SetFrameSinceStartup(0);

    while (loopCount < 5)
    {
        myTestAgent->btexec();

        if (loopCount < 4)
        {
            CHECK_EQUAL(1, myTestAgent->testVar_0);
        }
        else
        {
            CHECK_EQUAL(2, myTestAgent->testVar_0);
        }

        ++loopCount;
		behaviac::Workspace::GetInstance()->SetFrameSinceStartup(behaviac::Workspace::GetInstance()->GetFrameSinceStartup() + 1);
    }

    myTestAgent->resetProperties();
    myTestAgent->btexec();
    CHECK_EQUAL(1, myTestAgent->testVar_0);

    BEHAVIAC_DELETE(myTestAgent);
    behaviac::Agent::UnRegister<AgentNodeTest>();

    behaviac::Profiler::DestroyInstance();

    unregisterAllTypes();
}
开发者ID:Evilcoolkings,项目名称:behaviac,代码行数:48,代码来源:NodeUnitTest.cpp

示例3: test_stochastic_distribution_0

void test_stochastic_distribution_0(behaviac::string tree, behaviac::Workspace::EFileFormat format)
{
    behaviac::Profiler::CreateInstance();
    behaviac::Config::SetSocketing(false);
    behaviac::Config::SetLogging(false);

    //behaviac::Agent::Register<AgentNodeTest>();
    registerAllTypes();

    AgentNodeTest* myTestAgent = AgentNodeTest::DynamicCast(behaviac::Agent::Create<AgentNodeTest>());
    behaviac::Agent::SetIdMask(1);
    myTestAgent->SetIdFlag(1);
    //ms_workspace = new BehaviacWorkspace();
    myTestAgent->btload(tree.c_str());
    myTestAgent->btsetcurrent(tree.c_str());
    myTestAgent->resetProperties();

    int counts[3] = { 0, 0, 0 };
    int loopCount = STOCHASTIC_SAMPLE_COUNT;

    while (loopCount > 0)
    {
        myTestAgent->btexec();
        ++(counts[myTestAgent->testVar_0]);
        --loopCount;
    }

#if BEHAVIAC_COMPILER_MSVC

    for (int i = 0; i < 3; ++i)
    {
        int k = counts[i];
        int bias = abs(k - STOCHASTIC_SAMPLE_COUNT / 3);
        CHECK_LESS(bias, (STOCHASTIC_SAMPLE_COUNT / 20));
    }

#endif
    unregisterAllTypes();
    BEHAVIAC_DELETE(myTestAgent);
    //behaviac::Agent::UnRegister<AgentNodeTest>();

    behaviac::Profiler::DestroyInstance();
}
开发者ID:Evilcoolkings,项目名称:behaviac,代码行数:43,代码来源:NodeUnitTest.cpp

示例4: test_stochastic_distribution_1

void test_stochastic_distribution_1(behaviac::string tree, behaviac::Workspace::EFileFormat format,
                                    int loopCount = STOCHASTIC_SAMPLE_COUNT, int referenceValue = STOCHASTIC_SAMPLE_COUNT / 3, int checkValue = STOCHASTIC_SAMPLE_COUNT / 30)
{
    behaviac::Profiler::CreateInstance();
    behaviac::Config::SetSocketing(false);
    behaviac::Config::SetLogging(false);

    //behaviac::Agent::Register<AgentNodeTest>();
    registerAllTypes();
    AgentNodeTest* myTestAgent = AgentNodeTest::DynamicCast(behaviac::Agent::Create<AgentNodeTest>());
    behaviac::Agent::SetIdMask(1);
    myTestAgent->SetIdFlag(1);


    int predicateValueCount = 0;
    myTestAgent->btload(tree.c_str());
    myTestAgent->btsetcurrent(tree.c_str());
    myTestAgent->resetProperties();

    while (loopCount > 0)
    {
        myTestAgent->resetProperties();
        myTestAgent->btexec();

        if (myTestAgent->testVar_0 == 0)
        {
            predicateValueCount++;
        }

        --loopCount;
    }

#if BEHAVIAC_COMPILER_MSVC
    int bias = abs(predicateValueCount - referenceValue);
    CHECK_LESS(bias, checkValue);
#endif
    unregisterAllTypes();
    BEHAVIAC_DELETE(myTestAgent);
    //behaviac::Agent::UnRegister<AgentNodeTest>();

    behaviac::Profiler::DestroyInstance();
}
开发者ID:Evilcoolkings,项目名称:behaviac,代码行数:42,代码来源:NodeUnitTest.cpp

示例5: test_stochastic_distribution_2

//< Selector Probability Tests
void test_stochastic_distribution_2(behaviac::string tree, behaviac::Workspace::EFileFormat format, int refs[3])
{
    behaviac::Profiler::CreateInstance();
    behaviac::Config::SetSocketing(false);
    behaviac::Config::SetLogging(false);

    //behaviac::Agent::Register<AgentNodeTest>();
    registerAllTypes();
    AgentNodeTest* myTestAgent = AgentNodeTest::DynamicCast(behaviac::Agent::Create<AgentNodeTest>());
    behaviac::Agent::SetIdMask(1);
    myTestAgent->SetIdFlag(1);
    myTestAgent->btload(tree.c_str());
    myTestAgent->btsetcurrent(tree.c_str());
    myTestAgent->resetProperties();

    int counts[3] = { 0, 0, 0 };
    int loopCount = 10000;

    while (loopCount > 0)
    {
        myTestAgent->btexec();
        ++(counts[myTestAgent->testVar_0]);
        --loopCount;
    }

    for (int i = 0; i < 3; ++i)
    {
        int k = counts[i];
        int bias = abs(k - refs[i]);
        CHECK_LESS(bias, 1000);
    }

    unregisterAllTypes();
    BEHAVIAC_DELETE(myTestAgent);
    //behaviac::Agent::UnRegister<AgentNodeTest>();

    behaviac::Profiler::DestroyInstance();
}
开发者ID:Evilcoolkings,项目名称:behaviac,代码行数:39,代码来源:NodeUnitTest.cpp

示例6: initTestEnvNode

LOAD_TEST(btunittest, event_ut_0)
{
	AgentNodeTest* myTestAgent = initTestEnvNode("node_test/event_ut_0", format);

	ChildNodeTest* childTestAgent = ChildNodeTest::DynamicCast(behaviac::Agent::Create<ChildNodeTest>(100, "ChildNodeTest", 0, 0));
	CHECK_EQUAL(100, childTestAgent->testVar_0);

	myTestAgent->resetProperties();

	behaviac::EBTStatus status = myTestAgent->btexec();
	CHECK_EQUAL(behaviac::BT_RUNNING, status);

	behaviac::Workspace::GetInstance()->SetTimeSinceStartup(0);
	myTestAgent->FireEvent("event_test_void");
	CHECK_EQUAL(true, myTestAgent->event_test_var_bool);

	status = myTestAgent->btexec();
	CHECK_EQUAL(behaviac::BT_RUNNING, status);

	behaviac::Workspace::GetInstance()->SetTimeSinceStartup(5.1);

	status = myTestAgent->btexec();
	CHECK_EQUAL(behaviac::BT_RUNNING, status);

	myTestAgent->resetProperties();
	myTestAgent->btsetcurrent("node_test/event_ut_0");
	myTestAgent->btexec();
	myTestAgent->FireEvent("event_test_int", 13);
	CHECK_EQUAL(13, myTestAgent->event_test_var_int);

	myTestAgent->FireEvent("event_test_float2", myTestAgent->TestFloat2);
	myTestAgent->FireEvent("event_test_float2_ref", myTestAgent->TestFloat2);
			
	status = myTestAgent->btexec();
	CHECK_EQUAL(behaviac::BT_RUNNING, status);

	myTestAgent->resetProperties();
	myTestAgent->btsetcurrent("node_test/event_ut_0");
	myTestAgent->btexec();
	myTestAgent->FireEvent("event_test_int_bool", 15, true);
	CHECK_EQUAL(true, myTestAgent->event_test_var_bool);
	CHECK_EQUAL(15, myTestAgent->event_test_var_int);

	status = myTestAgent->btexec();
	CHECK_EQUAL(behaviac::BT_RUNNING, status);

	myTestAgent->resetProperties();
	myTestAgent->btexec();
	myTestAgent->FireEvent("event_test_int_bool_float", 15, true, 27.3f);
	CHECK_EQUAL(true, myTestAgent->event_test_var_bool);
	CHECK_EQUAL(15, myTestAgent->event_test_var_int);
	CHECK_FLOAT_EQUAL(27.3f, myTestAgent->event_test_var_float);

	status = myTestAgent->btexec();
	CHECK_EQUAL(behaviac::BT_RUNNING, status);

	myTestAgent->resetProperties();
	myTestAgent->btsetcurrent("node_test/event_ut_0");
	myTestAgent->btexec();
	myTestAgent->testVar_0 = 0;
	status = myTestAgent->btexec();
	CHECK_EQUAL(behaviac::BT_SUCCESS, status);
	CHECK_EQUAL(0, myTestAgent->testVar_1);

	myTestAgent->FireEvent("event_test_int_bool_float", 19, true, 11.9f);
	CHECK_EQUAL(false, myTestAgent->event_test_var_bool);
	CHECK_EQUAL(-1, myTestAgent->event_test_var_int);
	CHECK_FLOAT_EQUAL(-1.0f, myTestAgent->event_test_var_float);

	myTestAgent->resetProperties();
	myTestAgent->btsetcurrent("node_test/event_ut_0");
	myTestAgent->btexec();

	CHECK_EQUAL(NULL, myTestAgent->event_test_var_agent);
	myTestAgent->FireEvent("event_test_agent", myTestAgent);
	CHECK_EQUAL(true, myTestAgent->event_test_var_agent != NULL);

	myTestAgent->resetProperties();
	myTestAgent->btsetcurrent("node_test/event_ut_0");
	myTestAgent->btexec();

	CHECK_EQUAL(NULL, myTestAgent->event_test_var_agent);
	myTestAgent->FireEvent("event_test_agent", childTestAgent);
	CHECK_EQUAL(true, myTestAgent->event_test_var_agent != NULL);

	BEHAVIAC_DELETE(childTestAgent);

	finlTestEnvNode(myTestAgent);
}
开发者ID:AdamHyl,项目名称:behaviac,代码行数:89,代码来源:EventUnitTest.cpp


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