Ejemplo n.º 1
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();
}
Ejemplo n.º 2
0
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();
}
Ejemplo n.º 3
0
//< 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();
}
Ejemplo n.º 4
0
double RoadGraphMockSource::GetSpeedKMpH(FeatureID const & featureId,
                                         SpeedParams const & /* speedParams */) const
{
  CHECK_LESS(featureId.m_index, m_roads.size(), ("Invalid feature id."));
  return m_roads[featureId.m_index].m_speedKMPH;
}
Ejemplo n.º 5
0
IRoadGraph::RoadInfo RoadGraphMockSource::GetRoadInfo(FeatureID const & featureId,
                                                      SpeedParams const & /* speedParams */) const
{
  CHECK_LESS(featureId.m_index, m_roads.size(), ("Invalid feature id."));
  return m_roads[featureId.m_index];
}