void TestWorld1::process() { killHalf(); expireFood(); autoinsertFood(); expireCritters(); autosaveCritters(); autoinsertCritters(); // m_dynamicsWorld->stepSimulation(0.016667f); m_dynamicsWorld->stepSimulation(0.016667f, 0, 0.016667f); // m_dynamicsWorld->stepSimulation(Timer::Instance()->bullet_ms / 1000.f); renderVision(); grabVision(); unsigned int lmax = critters.size(); for( unsigned int i=0; i < lmax; i++) { CritterB *c = critters[i]; checkCollisions( c ); c->process(); freeEnergy += c->energyUsed; eat(c); procreate(c); } }
void Roundworld::process() { if ( !pause ) { killHalf(); expireFood(); autoinsertFood(); expireCritters(); autoexchangeCritters(); autosaveCritters(); autoinsertCritters(); // adjust gravity vectors of all entities' rigid bodies unsigned int j, b; Food* f; CritterB* bod; btRigidBody* bo; for( j=0; j < entities.size(); j++) { if ( entities[j]->type == FOOD ) { // f = food[j]; Food* f = static_cast<Food*>( entities[j] ); for( b=0; b < f->body.bodyparts.size(); b++) { bo = f->body.bodyparts[b]->body; bo->setGravity( -(bo->getCenterOfMassPosition().normalized()*10) ); } } } for( j=0; j < critters.size(); j++) { bod = critters[j]; for( b=0; b < bod->body.bodyparts.size(); b++) { bo = bod->body.bodyparts[b]->body; bo->setGravity( -(bo->getCenterOfMassPosition().normalized()*10) ); } } if ( *critter_raycastvision == 0 ) { renderVision(); grabVision(); } // do a bullet step m_dynamicsWorld->stepSimulation(0.016667f, 0, 0.016667f); // m_dynamicsWorld->stepSimulation(Timer::Instance()->bullet_ms / 1000.f); int lmax = (int)critters.size(); CritterB *c; float freeEnergyc = 0.0f; // FIXME USE FROM WORLDB omp_set_num_threads( *threads ); #pragma omp parallel for ordered shared(freeEnergyc, lmax) private(c) // ordered for( int i=0; i < lmax; i++) { c = critters[i]; omp_set_lock(&my_lock1); checkCollisions( c ); omp_unset_lock(&my_lock1); // process c->process(); // record critter used energy freeEnergyc += c->energyUsed; // process Output Neurons eat(c); // procreation if procreation energy trigger is hit omp_set_lock(&my_lock1); procreate(c); omp_unset_lock(&my_lock1); } freeEnergy += freeEnergyc; getGeneralStats(); } }