void CharacterPredictionSystem::stepNonLocalCharacter(const fsn::EntityRef& entity) { CharacterInputList::iterator removeUpTo = mInputs[entity.getID()].end(); for (auto it = mInputs[entity.getID()].begin(); it != mInputs[entity.getID()].end(); it++) { CharacterInputAt& input = *it; if (input.receivedLimit && input.ticksLeft == 0) { removeUpTo = it; continue; } if ((input.receivedLimit && input.ticksLeft > 0) || input.tick <= mTick-mStepDelay) { // Step player's physics auto newState = CharacterMover::step(mStates[entity.getID()].back(), createCharacterAction(entity, mStates[entity.getID()].back(), input.input)); setNewState(entity, newState); input.ticksStepped++; if (input.receivedLimit) input.ticksLeft--; break; } } if (!mInputs[entity.getID()].empty() && removeUpTo != mInputs[entity.getID()].end()) { mInputs[entity.getID()].erase(mInputs[entity.getID()].begin(), removeUpTo+1); } }
void BaseAnimatedStackedWidget::setCurrentWidget(QWidget* widget) { if (!widget) return; #ifdef ENABLE_YATOOLBOX_ANIMATION if (isVisible()) { QPixmap pix(normalPage()->size()); normalPage()->render(&pix); animationPage_->setStaticPixmap(pix); stackedWidget_->setCurrentWidget(animationPage_); setCurrentState(widget); } #endif #ifndef ENABLE_YATOOLBOX_ANIMATION setUpdatesEnabled(false); #endif setCurrentWidget_internal(widget); #ifndef ENABLE_YATOOLBOX_ANIMATION if (isVisible()) { activateNormalPageLayout(); setUpdatesEnabled(true); } #endif #ifdef ENABLE_YATOOLBOX_ANIMATION if (isVisible()) { setNewState(); animationPage_->start(); } #endif }
void MenuState::loader() { //load //initial loading std::ifstream s("saves/save_player.bin"); if(!s.is_open()) return; int profession; std::string name; s >> profession; s >> name; s.close(); //creating and loading player Player* player; switch(profession) { case 0: //archer player = new CArcher(name); break; case 1: //mage player = new CMage(name); break; case 2: //knight player = new CKnight(name); break; default: player = NULL; break; } player->load(); dynamic_cast<GameState*>(engine->getStateManager()->getStateObject(EState::Game))->player = player; //loading map Level *l = new Level("saves/save_map.bin", player, false, engine->getSoundManager()); dynamic_cast<GameState*>(engine->getStateManager()->getStateObject(EState::Game))->lvl = l; setNewState(EState::Game); }
void MainWindow::showStateConfigDlg() { if(!stateDlg){ stateDlg = new StateConfigDlg(this); connect(stateDlg,SIGNAL(sendState(QString)),this,SLOT(setNewState(QString))); } stateDlg->show(); stateDlg->raise(); stateDlg->activateWindow(); }
void LandlineDialer::timerEvent(QTimerEvent* /*event*/) { setNewState(); }
void DDT2D::DDTSimulatedAnnealing ( Container <Node3DCartesian <T> *> &nl, Container <HalfEdge <T> *> &half_edges, unsigned short swap_criterion_selected, const bool print_message, const bool print_exception, std::ostream * output ) { //DelaunayTriangulation2D using simulated annealing algorithm try { //Initial and minimal temperatures float t0 = 200; //Initial temperature const float tmin = 5; //Minimum temperature const float r = 0.95f; //Annealing ratio r = (0.9, 0.95) //Do LOP as the first iteration DDTLOP ( nl, half_edges, swap_criterion_selected, print_message ); const unsigned int glimit_multiplier = 5; //Good swaps glimit ratio, multiplier = 5 * n //Number of good swaps glimit= 5 * n const unsigned int nlimit_multiplier = 10; //Multiplier of iterations for each temperature = 10 * n float k = 0; //Power of the Boltzmann equation //Iterations and global cost unsigned int iterations = 0; //Counter of iterations T global_cost_old = globalCostFunction ( half_edges ); T global_cost = global_cost_old; //Automatic t0 temperature set bool automatic_t0_set = true; //Automatic setting of the temperature //Total half edges const unsigned int n = half_edges.size(); //Set new glimit and nlimit const unsigned int nlimit = nlimit_multiplier * n; const unsigned int glimit = glimit_multiplier * n; //Set initial temperature if ( automatic_t0_set ) { //Get initial temperature from analysis of cost differences t0 = getInitialTemperature ( half_edges ); } //Assign tk to t0 float tk = t0; //Compute number of temperature states unsigned int total_tk_states = ( unsigned int ) ( 1 + ( log ( tmin ) - log ( t0 ) ) / ( log ( 0.95 ) ) ); //Initialize random number generator srand ( ( unsigned ) time ( 0 ) ); //Print info if ( print_message ) { *output << "> Starting DDT, Simulated Annealing, please wait..." << std::endl; } //Do until the temperature is frozen (tk > MIN_TEMPERATURE) do { //Good swap indicator unsigned int good_swap = 0; //Total iterations for temperature tk unsigned int iterations_tk = 0; // Set new stat for temperature tk (MAX_ITERATIONS or GODD SWAP found) do { //Set state setNewState ( tk, good_swap, n, global_cost, half_edges ); //Increase iteration for the temperature tk (compare with n limit for each tk) iterations_tk ++; //Global iterations count (only for information) iterations ++; } // Repeat if good_swaps < glimit while ( good_swap < glimit ); //Set good swap to 0 good_swap = 0; //Set new decreased temperature tk = pow ( r, ( int ) k ) * t0; //Increase power of the Boltzmann equation k++; // Update counter if ( ( ( unsigned short ) ( 100.0 * ( k / total_tk_states ) ) ) % 1 == 0 ) { *output << "."; } } while ( tk > tmin ); //Global cost after swapping const T global_cost_new = globalCostFunction ( half_edges ); //Compute change ratio T ddt_ratio = 0; if ( global_cost != global_cost_old ) { ddt_ratio = 100 * ( global_cost - global_cost_old ) / global_cost_old; } //Print info if ( print_message ) { *output << std::endl << "Finished..." << "Total iterations: " << iterations << std::endl; *output << "> DT global cost old: " << global_cost_old << " DT global cost new: " << global_cost << ", ratio: " << ddt_ratio << "%" << std::endl; } } //Throw exception catch ( Error & error ) { if ( print_exception ) { error.printException ( output ); } //Delete lists half_edges->clear(); *output << "DDT canceled..." << std::endl; throw; } }
void VoipDialer::timerEvent(QTimerEvent* /*event*/) { setNewState(); }