本文整理汇总了C++中CField::SetTrafficLightForCars方法的典型用法代码示例。如果您正苦于以下问题:C++ CField::SetTrafficLightForCars方法的具体用法?C++ CField::SetTrafficLightForCars怎么用?C++ CField::SetTrafficLightForCars使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CField
的用法示例。
在下文中一共展示了CField::SetTrafficLightForCars方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessModel
//.........这里部分代码省略.........
int Strategy = m_pOptimalTLight->GetOptValue();
GreenTime = m_CyclesPerTrafficLight*0.8*m_TrafficLightVariants[Strategy];
YellowTime = m_CyclesPerTrafficLight * 0.2;
RedTime = m_CyclesPerTrafficLight - GreenTime - YellowTime;
};
pInfoPanel->SetTrafficLightDistribution((float)GreenTime/m_CyclesPerTrafficLight, (float)RedTime/m_CyclesPerTrafficLight, (float)YellowTime/m_CyclesPerTrafficLight);
Counter = 0;
TMode = Green;
};
if (Counter >= GreenTime)
{
TMode = Yellow;
};
if (Counter >= GreenTime + YellowTime/2)
{
TMode = Red;
};
if (Counter >= GreenTime + YellowTime/2 + RedTime)
{
TMode = Yellow;
};
CMovingObject *pObject;
#ifdef CONST_NUMBER_OF_MO
for (int car = 0; car < static_cast<int>(m_SpeedCarAppearance[day1][TypeOfTime][weather]); car++)
{
pObject = new CCar();
pField->AddObject(pObject);
};
if (rand() <= RAND_MAX*(m_SpeedCarAppearance[day1][TypeOfTime][weather] - static_cast<int>(m_SpeedCarAppearance[day1][TypeOfTime][weather])))
{
pObject = new CCar();
pField->AddObject(pObject);
};
for (int human = 0; human < static_cast<int>(m_SpeedHumanAppearance[day1][TypeOfTime][weather]); human++)
{
pObject = new CHuman();
pField->AddObject(pObject);
};
if (rand() <= RAND_MAX*(m_SpeedHumanAppearance[day1][TypeOfTime][weather] - static_cast<int>(m_SpeedHumanAppearance[day1][TypeOfTime][weather])))
{
pObject = new CHuman();
pField->AddObject(pObject);
};
#else
pCarDistrib->SetLambda(m_SpeedCarAppearance[day1][TypeOfTime][weather]);
int NNewCars = pCarDistrib->getPuassonValue();
for (int car = 0; car < NNewCars; car++)
{
pObject = new CCar();
pField->AddObject(pObject);
};
pCarDistrib->SetLambda(m_SpeedHumanAppearance[day1][TypeOfTime][weather]);
int NNewHumans = pCarDistrib->getPuassonValue();
for (int human = 0; human < NNewHumans; human++)
{
pObject = new CHuman();
pField->AddObject(pObject);
};
#endif
pField->SetTrafficLightForCars(TMode);
pField->Move();
if (pInfoPanel != NULL)
{
pInfoPanel->SetDay(day);
pInfoPanel->SetTime(Hours, Minutes);
pInfoPanel->SetNumbersOfCarsAndHumans(pField->GetNumberOfCars(), pField->GetNumberOfHumans());
pInfoPanel->SetSpeedOfCarsAndHumans(CCar::GetDefaultSpeed(), CHuman::GetDefaultSpeed());
pInfoPanel->SetSpeedOfCarAndHumanAppearance(m_SpeedCarAppearance[day1][TypeOfTime][weather], m_SpeedHumanAppearance[day1][TypeOfTime][weather]);
pInfoPanel->Invalidate(FALSE);
};
pEngine->Invalidate(FALSE);
Sleep(10);
};
time = 0;
};
day = Monday;
};
delete pCarDistrib;
}