本文整理汇总了C++中Think函数的典型用法代码示例。如果您正苦于以下问题:C++ Think函数的具体用法?C++ Think怎么用?C++ Think使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Think函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Think
/*
=================
rvEffect::ClientPredictionThink
=================
*/
void rvEffect::ClientPredictionThink( void ) {
if ( gameLocal.isNewFrame ) {
Think ( );
}
RunPhysics();
Present();
}
示例2: SDL_GetTicks
//handles the updating routines.
void CEngine::DoThink()
{
long iElapsedTicks = SDL_GetTicks() - m_lLastTick;
m_lLastTick = SDL_GetTicks();
Think(iElapsedTicks);
m_iFPSTickCounter += iElapsedTicks;
}
示例3: Think
/*
================
idItem::ClientPredictionThink
================
*/
void idItem::ClientPredictionThink( void ) {
// only think forward because the state is not synced through snapshots
if ( !gameLocal.isNewFrame ) {
return;
}
Think();
}
示例4: Philosopher
void Philosopher(int phil) {
Think(phil);
int first = phil;
int second = (phil+1)%PHIL_COUNT;
pthread_mutex_lock(&footman_mutex);
while (footman_count == (PHIL_COUNT-1)) pthread_cond_wait(&footman_cond, &footman_mutex);
footman_count++;
pthread_mutex_unlock(&footman_mutex);
pthread_mutex_lock(&chopstick_mutexes[first]);
pthread_mutex_lock(&chopstick_mutexes[second]);
Eat(phil);
pthread_mutex_unlock(&chopstick_mutexes[first]);
pthread_mutex_unlock(&chopstick_mutexes[second]);
pthread_mutex_lock(&footman_mutex);
footman_count--;
pthread_cond_signal(&footman_cond);
pthread_mutex_unlock(&footman_mutex);
}
示例5: while
void CLogicThread::ThinkAllAffectedSentence(CTaskDialog* Dialog){
deque<InfectedText>::iterator It = m_Text.m_InfectedSentenceList.begin();
while(It != m_Text.m_InfectedSentenceList.end()){
InfectedText& Text = *It;
Think(Dialog,(CSentence*)Text.Text,Text.AlterPos);
It++;
}
m_Text.m_InfectedSentenceList.clear();
};
示例6: ParseGo
void ParseGo(POS *p, char *ptr) {
char token[180], bestmove_str[6], ponder_str[6];
int pv[MAX_PLY];
Timer.Clear();
pondering = 0;
for (;;) {
ptr = ParseToken(ptr, token);
if (*token == '\0')
break;
if (strcmp(token, "ponder") == 0) {
pondering = 1;
} else if (strcmp(token, "wtime") == 0) {
ptr = ParseToken(ptr, token);
Timer.SetData(W_TIME, atoi(token));
} else if (strcmp(token, "btime") == 0) {
ptr = ParseToken(ptr, token);
Timer.SetData(B_TIME, atoi(token));
} else if (strcmp(token, "winc") == 0) {
ptr = ParseToken(ptr, token);
Timer.SetData(W_INC, atoi(token));
} else if (strcmp(token, "binc") == 0) {
ptr = ParseToken(ptr, token);
Timer.SetData(B_INC, atoi(token));
} else if (strcmp(token, "movestogo") == 0) {
ptr = ParseToken(ptr, token);
Timer.SetData(MOVES_TO_GO, atoi(token));
} else if (strcmp(token, "nodes") == 0) {
ptr = ParseToken(ptr, token);
Timer.SetData(FLAG_INFINITE, 1);
Timer.SetData(MAX_NODES, atoi(token));
} else if (strcmp(token, "movetime") == 0) {
ptr = ParseToken(ptr, token);
Timer.SetData(MOVE_TIME, atoi(token) );
} else if (strcmp(token, "depth") == 0) {
ptr = ParseToken(ptr, token);
Timer.SetData(FLAG_INFINITE, 1);
Timer.SetData(MAX_DEPTH, atoi(token));
} else if (strcmp(token, "infinite") == 0) {
Timer.SetData(FLAG_INFINITE, 1);
}
}
Timer.SetSideData(p->side);
Timer.SetMoveTiming();
Think(p, pv);
MoveToStr(pv[0], bestmove_str);
if (pv[1]) {
MoveToStr(pv[1], ponder_str);
printf("bestmove %s ponder %s\n", bestmove_str, ponder_str);
} else
printf("bestmove %s\n", bestmove_str);
}
示例7: Think
void EnvironmentObject::render() {
Think();
if (camera->frustum.pointInFrustum(position)) {
model->setScale(scale);
model->setPosition(position);
model->setRotation(rotation);
glBindTexture(GL_TEXTURE_2D,texture);
model->drawObjectFrame(1,model->kDrawImmediate);
}
}
示例8: Think
/*
================
idBrittleFracture::ClientThink
================
*/
void idBrittleFracture::ClientThink( const int curTime, const float fraction, const bool predict )
{
// only think forward because the state is not synced through snapshots
if( !gameLocal.isNewFrame )
{
return;
}
Think();
}
示例9: Think
bool FXParticle::Update( void )
{
// There should be a think function, otherwise what's the point of using a particle?
if ( Think )
{
// All particle attributes need to be updated in the think function since
// nothing is auto-updated. This is done to ensure the most flexibility.
return Think( this, m_cowner );
}
return true;
}
示例10: UpdatePhysics
void CChickenBoid::Update(float dt,SBoidContext &bc)
{
if(m_physicsControlled)
{
UpdatePhysics(dt,bc);
if(m_bThrown && m_pPhysics)
{
pe_status_awake tmp;
bool bAwake = m_pPhysics->GetStatus(&tmp) != 0;
if(!bAwake)
{
// Falled on ground after being thrown.
m_bThrown = false;
m_physicsControlled = false;
}
}
return;
}
if(m_dead)
return;
m_lastThinkTime += dt;
if(bc.waterLevel > bc.terrainZ)
bc.terrainZ = bc.waterLevel;
if(bc.followPlayer)
{
if(m_pos.GetSquaredDistance(bc.playerPos) > MAX_CHICKEN_DISTANCE_FROM_PLAYER*MAX_CHICKEN_DISTANCE_FROM_PLAYER)
{
float z = bc.MinHeight + (Boid::Frand()+1)/2.0f*(bc.MaxHeight - bc.MinHeight);
m_pos = bc.playerPos + Vec3(Boid::Frand()*MAX_CHICKEN_DISTANCE_FROM_PLAYER,Boid::Frand()*MAX_CHICKEN_DISTANCE_FROM_PLAYER,z);
m_pos.z = bc.engine->GetTerrainElevation(m_pos.x,m_pos.y) + bc.fBoidRadius*0.5f;
m_speed = bc.MinSpeed;
m_heading = Vec3(Boid::Frand(),Boid::Frand(),0).GetNormalized();
}
}
Think(dt,bc);
if(!m_landing)
{
// Calc movement with current velocity.
CalcMovement(dt,bc,true);
UpdateAnimationSpeed(bc);
m_accel.Set(0,0,0);
}
}
示例11: while
void *action(void* id)
{
int tid = (int)id;
while(1)
{
printf("Philosopher #%d is going to eat.\n", tid);
Eat(tid, model_eat);
printf("Philosopher #%d 's eating is done.\n", tid);
Think(tid, model_think);
}
return NULL;
}
示例12: switch
void aiC::Execute(bool serverHasUpdatedGameState)
{
switch(aiStatus) {
// just started, need to connect with server
case 0:
if(netConnected()) aiStatus++;
else if(timeGet() - aiLastCommand > 2000)
{
pf("ai %s, trying to connect:\n", Name);
cmd("name AI-%s", Name);
cmd("join localhost");
aiLastCommand = timeGet();
}
break;
// waiting for other players to join
case 1:
if(game && game->Turn > 0) aiStatus++;
else
//if(playercount() > 1)
if(timeGet() - aiLastCommand > 2000)
{
cmd("ready");
aiLastCommand = timeGet();
}
break;
// choose picks
case 2:
if(self->Status == BRAIN_ACTIVE) aiStatus++;
else if(timeGet() - aiLastCommand > 2000)
{
Pick();
aiLastCommand = timeGet();
}
// play
case 3:
if(serverHasUpdatedGameState)
Think();
break;
}
}
示例13: Eat
void Eat()
{
std::cout << name_ << ": Begin eating" << std::endl;
int lockAIndex = holdForkIndex_;
int lockBIndex = (holdForkIndex_ + 1) % MAX_FORKS;
std::lock(fork[lockAIndex], fork[lockBIndex]);
Think();
std::lock_guard<std::mutex> locka(fork[lockAIndex], std::adopt_lock);
std::cout << name_ << ": Hold fork: " << lockAIndex << std::endl;
Think();
std::lock_guard<std::mutex> lockb(fork[lockBIndex], std::adopt_lock);
std::cout << name_ << ": Hold fork: " << lockBIndex << std::endl;
// eating
std::this_thread::sleep_for(std::chrono::microseconds(10));
std::cout << name_ << " End eating" << std::endl;
}
示例14: Think
void DBot::Tick ()
{
Super::Tick ();
if (player->mo == NULL || bglobal.freeze)
{
return;
}
BotThinkCycles.Clock();
bglobal.m_Thinking = true;
Think ();
bglobal.m_Thinking = false;
BotThinkCycles.Unclock();
}
示例15: _stepBeginMethod
///
/// Run one step of the application
///
void SceneManager::Step(void)
{
// Invoke begin method
if(_stepBeginMethod != NULL)
_stepBeginMethod();
// Check frame time
if(_renderWindow->GetFrameTime() > 0)
{
// Check events
_eventListener->CheckEvents();
// Think methods
Think(_environementProvider->GetAeroplaneArray()[0]);
}
// Set scene view
_renderWindow->SetView(*_sceneView);
_sceneView->SetCenter(sf::Vector2f(
GetEnvironementProvider()->GetAeroplaneArray()[0]->GetPosition().x,
std::min<float>(GetEnvironementProvider()->GetAeroplaneArray()[0]->GetPosition().y,_renderWindow->GetHeight()/2.f)));
_sceneView->SetHalfSize(400.f*_zoomFactor, 300.f*_zoomFactor);
//Draw methods
_renderWindow->Clear(sf::Color(150,186,219));
Draw(_sceneImageSprite);
Draw(GetEnvironementProvider()->GetAeroplaneArray()[0]);
// Set DashBoard view
_renderWindow->SetView(_renderWindow->GetDefaultView());
// Set FrameRate
_frameRate = 1/_renderWindow->GetFrameTime();
// Draw dashboard
_dashboard->Draw(_renderWindow);
// Display renderWindow
_renderWindow->Display();
// Invoke end method
if(_stepEndMethod != NULL)
_stepEndMethod();
}