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


C++ CField::GetNumberOfCars方法代码示例

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


在下文中一共展示了CField::GetNumberOfCars方法的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;
}
开发者ID:billryan,项目名称:OpenPNL,代码行数:101,代码来源:Nature.cpp


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