/** * \brief Updates the position of the object controlled by this movement. * * This function is called repeatedly. * You can redefine this function. */ void Movement::update() { if (!finished && is_finished()) { finished = true; notify_movement_finished(); } else if (finished && !is_finished()) { finished = false; } }
/** * @brief Updates the position of the object controlled by this movement. * * This function is called repeteadly. * You can redefine this function. */ void Movement::update() { if (!finished && is_finished()) { finished = true; if (entity != NULL) { entity->notify_movement_finished(); } } else if (finished && !is_finished()) { finished = false; } }
/* metoda care translateaza mingea si determina daca un joc s-a terminat sau nu, * respectiv modifica scorul pentru echipa care a dat gol */ void Game::passBall (bool &animation) { players[has_ball]->pass(ball); if (abs(ball->getCenter().y) - ball->getRay() > MAX_UP) { animation = false; ball->remove(); if (ball->getCenter().y > 0) { modifyScore("BLUE"); restore_ball("RED"); } if (ball->getCenter().y < 0) { modifyScore("RED"); restore_ball("BLUE"); } if (is_finished()) { restart(); } return; } for (int i = 0; i < NR_PLAYERS; i++) { if (ball->getDist(ball->getCenter(), players[i]->getCenter()) <= ball->getRay() + players[i]->getRay()) { animation = false; has_ball = i; } } }
void Game::status(std::ostream& os) const { os << "turn " << turn << "/" << turn_max; if (is_finished()) os << " finished"; os << std::endl; const int winner_id = state.get_winner(); const int colors[] = {31,34,32,33}; for (int kk=0; kk<static_cast<int>(hero_infos.size()); kk++) { const HeroInfo& hero_info = hero_infos[kk]; if (kk == winner_id) os << "* "; else os << " "; os << "@" << (kk+1) << " "; os << "\033[" << colors[kk] << "m" << hero_info.name << "\033[0m"; if (hero_info.is_real_bot()) os << "(" << hero_info.elo << ")"; if (hero_info.crashed) { std::cout << " (crashed)"; } os << std::endl; } state.status(os); }
Scheduler::PhysicalTaskPtr Scheduler::take_runnable_task(const Locality &locality){ const auto tid = locality.self_thread_id(); PhysicalTaskPtr task; // try to take an unstealable task task = take_unstealable_task(locality); if(task){ return task; } // try to take a local stealable task task = take_local_stealable_task(locality); if(task){ return task; } // try to steal an task task = steal_task(locality); if(task){ return task; } // attempt to sleep auto &sync = m_synchronizers[tid]; while(true){ sync.set_is_sleeping(); if(task || is_finished() || is_cancelled()){ break; } // try to take an unstealable task task = take_unstealable_task(locality); if(task){ break; } // try to steal an task task = steal_task(locality); if(task){ break; } // wait for new task sync.wait(); } sync.reset_is_sleeping(); return task; }
/** * \brief Updates the timer. */ void Timer::update() { if (suspended || is_finished()) { return; } // check the time uint32_t now = System::now(); finished = (now >= expiration_date); // play the sound if (is_with_sound() && now >= next_sound_date) { uint32_t remaining_time = expiration_date - now; if (remaining_time > 6000) { Sound::play("timer"); next_sound_date += 1000; } else { Sound::play("timer_hurry"); if (remaining_time > 2000) { next_sound_date += 1000; } else { next_sound_date += 250; } } } }
t_match *check_space_pvp(t_match *match, int flag) { int check; check = 0; if (check_list(match) == 1) { flag = 1; return (match); } check = init_check(match); if (is_ok(match, check) == 1) { flag = 1; return (match); } flag = burn_select(&match, flag); if (flag != 0) { is_finished(match); if (who_play == 0) who_play = 42; else who_play = 0; } return (match); }
void TypeInferer::recalc_node (Node *node) { //fprintf (stderr, "tinf::recalc_node %d %p %s\n", get_thread_id(), node, node->get_description().c_str()); if (node->try_start_recalc()) { Q->push (node); } else if (is_finished()) { kphp_assert (node->get_holder_id() == get_thread_id()); } }
void CCounter::wait_finish() { sys::LockHelper<sys::CLock> lh(_lock); while (!is_finished()) { _event.wait(_lock); } }
void CCounter::inc_num_sender_finished() { sys::LockHelper<sys::CLock> lh(_lock); atomic_inc(&_num_sender_finished); if (is_finished()) { _event.signal(); } }
Report* Fight::start(ls::VM& vm, ls::VM& vm_v1) { Simulator::fight = this; for (auto& team : teams) { for (auto& entity : team->entities) { entities.insert({entity->id, entity}); order.addEntity(entity); entity->ai->compile(vm, vm_v1); } } actions.add(new ActionStartFight()); while (order.getTurn() <= MAX_TURNS) { auto entity = order.current(); Simulator::entity = entity; vm.output = entity->debug_output; vm_v1.output = entity->debug_output; LOG << "Turn of " << entity->name << " (" << entity->id << "), AI " << entity->ai->name << "..." << std::endl; actions.add(new ActionEntityTurn(entity)); entity->start_turn(); try { entity->ai->execute(vm, vm_v1); } catch (ls::vm::ExceptionObj* ex) { LOG << ex->to_string(true); // vm.last_exception = nullptr; // vm_v1.last_exception = nullptr; if (ex->type == ls::vm::Exception::OPERATION_LIMIT_EXCEEDED) { actions.add(new ActionAIError(entity)); // TODO Add Breaker Trophy } // TODO delete ex } vm.operations = 0; entity->end_turn(); actions.add(new ActionEndTurn(entity)); if (is_finished()) { break; } if (order.next()) { actions.add(new ActionNewTurn(order.getTurn())); LOG << "Turn " << order.getTurn() << std::endl; } } Simulator::entity = nullptr; Report* report = new Report(this); report->actions = &actions; return report; }
/** * \brief Updates this transition effect. * * This function is called repeatedly while the transition exists. */ void TransitionScrolling::update() { if (!is_started() || is_suspended()) { return; } uint32_t now = System::now(); while (now >= next_scroll_date && !is_finished()) { scroll(); next_scroll_date += 10; } }
bool bfs(command_seq *result_com) { int i; sq.init(); status ss, ss2; ss.cs.com_num = 0; for(i = 0; i < n; i++) { ss.st.top = 0; ss.st.value[i][0] = x[i]; } if(is_finished(ss.st)) { *result_com = ss.cs; return true; } sq.push(ss); while(!sq.empty()) { ss = sq.peek_front(); sq.pop(); for(i = 0; i < 5; i++) { ss2 = ss; if((*op_set[i])(&ss2.cs, &ss2.st)) { if(is_finished(ss2.st)) { *result_com = ss2.cs; return true; } if(ss2.cs.com_num < MAX_COM) sq.push(ss2); } } } return false; }
/** * \brief Update the base_tweener of a given amount of time. * \param dt The duration of the update in time units since the last call. * \return The amount of extra time in dt after the end of the update. */ double claw::tween::base_tweener::update( double dt ) { CLAW_PRECOND( dt >= 0 ); const double result = do_update(dt); if ( is_finished() ) notify_finished(); CLAW_POSTCOND( result <= dt ); CLAW_POSTCOND( result >= 0 ); return result; } // base_tweener::update()
/** * \brief Go forward in the animation. * \param t Go this dutation forward. * \pre t >= 0 */ void bear::visual::animation::next( double t ) { CLAW_PRECOND( t >= 0 ); if ( !is_finished() ) { m_time += m_time_factor * t; while ( ( m_time >= get_scaled_duration(get_current_index()) ) && !sprite_sequence::is_finished() ) { m_time -= get_scaled_duration(get_current_index()); sprite_sequence::next(); } } } // animation::next()
int main(int ac, char **av) { int fd[ac]; int return_val[ac]; char *line; int i; line = NULL; if (ac == 1) { read_stdin(line); return (0); } i = 0; while (++i < ac) { fd[i - 1] = open(av[i], O_RDONLY); if (fd[i - 1] == -1) { ft_putendl("erreur lors de l'ouverture du fichier"); return (-1); } return_val[i - 1] = 1; } i = 0; while (!is_finished(return_val, ac)) { return_val[i] = get_next_line(fd[i], &line); if (return_val[i] == 1) ft_putendl(line); i++; if (i == ac - 1) i = 0; free(line); } }
///<summary> /// 経過時刻を単位付き文字列で返す ///</summary> const std::string Timer::to_string() const { if (!is_finished()) return "NOT FINISHED"; return std::to_string(duration()) + "[sec]"; }
virtual table_element operator*() { SASSERT(!is_finished()); return m_parent[m_index]; }
/** * \brief Returns whether the transition effect is started and not finished yet. * \return true if the transition effect is started */ bool TransitionFade::is_started() const { return alpha != -1 && !is_finished(); }
bool torrent_handle::is_finished() const { INVARIANT_CHECK; TORRENT_FORWARD_RETURN(is_finished(), false); }
/** * \brief Go on the next change. */ void bf::action_player::next() { if ( !is_finished() ) next( get_duration_until_next() ); } // action_player::next()
/** * \brief Returns whether the transition effect is started. * \return false */ bool TransitionScrolling::is_started() const { return !is_finished(); }
table_element operator*() override { SASSERT(!is_finished()); return m_parent[m_index]; }
//write read #2 void * second_writer_func(void *a) { int thread_id = ((slurp_fastq_struct *) a)->thread_id; char *fastq2 = ((slurp_fastq_struct *) a)->fastq2; FILE *f2 = fopen(fastq2, "w"); fastq *read = malloc(sizeof(fastq)); int strand; assert(read); //Determine the conversions to make if(config.directional) { strand = (thread_id-1) % 2; } else { strand = (thread_id-1) % 4; } //Initialize the fastq struct read->max_name1 = 10; read->max_name2 = 10; read->max_seq1 = 10; read->max_seq2 = 10; read->max_qual1 = 10; read->max_qual2 = 10; read->name1 = malloc(sizeof(char) * 10); read->seq1 = malloc(sizeof(char) * 10); read->qual1 = malloc(sizeof(char) * 10); read->name2 = malloc(sizeof(char) * 10); read->seq2 = malloc(sizeof(char) * 10); read->qual2 = malloc(sizeof(char) * 10); assert(read->name1); assert(read->seq1); assert(read->qual1); assert(read->name2); assert(read->seq2); assert(read->qual2); while(1) { while(!is_ready(second_writer, 0)); //Sleeping slows things down too much if(is_finished(second_writer)) break; //Unpack read = unpack_fastq(read, second_writer->next->packed); //Remove from the linked list remove_raw_element(second_writer); //Convert switch(strand) { case 0 : case 1 : convertGA(read, 1); break; case 2 : case 3 : convertCT(read, 1); break; } fprintf(f2, "%s%s+\n%s", read->name2, read->seq2, read->qual2); } //Free things up fclose(f2); free(read->name1); free(read->seq1); free(read->qual1); free(read->name2); free(read->seq2); free(read->qual2); free(read); destroy_list(second_writer); return NULL; }