main() { struct person iwao = {0, 0}; struct person naoaki = {0, 0}; int i; int rand_num; //srand(0); for (i = 0; i < 10; i++) { update_step(&iwao); update_step(&naoaki); if (i % 2 == 0) { iwao.x += iwao.step; naoaki.x += naoaki.step; } else { iwao.y += iwao.step; naoaki.y += naoaki.step; } //printf("iwao +%d (%d, %d)\n", iwao.step, iwao.x, iwao.y); //printf("naoaki +%d (%d, %d)\n", naoaki.step, naoaki.x, naoaki.y); } printf("Iwao (%d, %d)\n", iwao.x, iwao.y); printf("Naoaki (%d, %d)\n", naoaki.x, naoaki.y); return 0; }
static void YMZ280B_state_save_update_step(ymz280b_state *chip) { int j; for (j = 0; j < 8; j++) { struct YMZ280BVoice *voice = &chip->voice[j]; update_step(chip, voice); if(voice->irq_schedule) chip->device->machine().scheduler().timer_set(attotime::zero, update_irq_state_cb[j].func, update_irq_state_cb[j].name, 0, chip); } }
static void YMZ280B_state_save_update_step(void *param) { struct YMZ280BChip *chip = param; int j; for (j = 0; j < 8; j++) { struct YMZ280BVoice *voice = &chip->voice[j]; update_step(chip, voice); if(voice->irq_schedule) timer_set_ptr(0, chip, update_irq_state_cb[j]); } }
static STATE_POSTLOAD( YMZ280B_state_save_update_step ) { ymz280b_state *chip = (ymz280b_state *)param; int j; for (j = 0; j < 8; j++) { struct YMZ280BVoice *voice = &chip->voice[j]; update_step(chip, voice); if(voice->irq_schedule) timer_set(machine, attotime_zero, chip, 0, update_irq_state_cb[j]); } }
main() { struct person iwao = {"Iwao", 0, 0}; struct person naoaki = {"Naoaki", 0, 0}; int i; int rand_num; //srand(0); for (i = 0; i < 10; i++) { update_step(&iwao); update_step(&naoaki); if (i % 2 == 0) { iwao.x += iwao.step; naoaki.x += naoaki.step; } else { iwao.y += iwao.step; naoaki.y += naoaki.step; } } print_position(iwao); print_position(naoaki); return 0; }
void JointActionsMap::update() { // Throw an error if one factor is not defined. for (std::vector<Action *> &factor : factoredActions) { if (factor.size() == 0) { throw ActionException(); } } actions.clear(); std::vector<Action *> create; update_step(create, 0); }
void FactoredStatesMap::update() { // Throw an error if one factor is not defined. for (std::vector<State *> &factor : factoredStates) { if (factor.size() == 0) { throw StateException(); } } states.clear(); std::vector<State *> create; update_step(create, 0); }
/*! * \brief Compute k-means clustering of the body image. * * This is an implementation of the K-means algorithm and it is used * to detect the hand within the body depth image. Body image is * clustered in two class: hand, and the rest of body. Clustering is * related only to depth values (scalar). * * \param[in] matrix (vector) of depth values to cluster * \param[out] vector of the cluster's means * \parma[out] vector of partitions index * \return min depth value */ int kmeans_clustering (CvMat *data, CvMat *means, CvMat *par) { CvMat *weights = cvCreateMat(K, 1, CV_32FC1); int min = init_step(data, means, weights); int i; for (i=0; i<data->rows; i++) { double val = cvmGet(data, i, 0); int idx = assignment_step(val, means); update_step(val, idx, means, weights); } //mk_partition(data, par, means); return min; }
void JointActionsMap::update_step(std::vector<Action *> currentJointAction, unsigned int currentFactorIndex) { // At the final factor index, we need to create a bunch of joint actions. for (Action *action : factoredActions[currentFactorIndex]) { // Begin by pushing a current factor's action on the vector (tuple). currentJointAction.push_back(action); // If this is the final index, then create a joint action object and append it to the list of actions. // Otherwise, recurse to the next index, using the new currentJointAction object. if (currentFactorIndex == factoredActions.size() - 1) { JointAction *newAction = new JointAction(currentJointAction); actions[newAction->hash_value()] = newAction; } else { update_step(currentJointAction, currentFactorIndex + 1); } // Pop off the action that was just appended, to prepare for the next loop. currentJointAction.pop_back(); } }
void FactoredStatesMap::update_step(std::vector<State *> currentFactoredState, unsigned int currentFactorIndex) { // At the final factor index, we need to create a bunch of factored states. for (State *state : factoredStates[currentFactorIndex]) { // Begin by pushing a current factor's state on the vector (tuple). currentFactoredState.push_back(state); // If this is the final index, then create a factored state object and append it to the list of states. // Otherwise, recurse to the next index, using the new currentFactoredState object. if (currentFactorIndex == factoredStates.size() - 1) { FactoredState *newState = new FactoredState(currentFactoredState); states[newState->hash_value()] = newState; } else { update_step(currentFactoredState, currentFactorIndex + 1); } // Pop off the state that was just appended, to prepare for the next loop. currentFactoredState.pop_back(); } }
int main() { unsigned int i; size_t max_step = 1; char word[20]; char temp[20]; struct HashMapNode* pnode; while(scanf("%s", word) != EOF) { pnode = hash_insert(word); pnode->step = 1; if(hash_map.size > 1) { for(i = 0; i < pnode->word_len; i++) { // same length strcpy(temp, word); while(--temp[i] >= 'a') { update_step(temp, pnode); if(pnode->step > max_step) goto out; } // length + 1 if(pnode->word_len < MAX_LEN) { strncpy(temp, word, i); temp[i] = 'z' + 1; strcpy(temp + i + 1, word + i); while(--temp[i] >= 'a') { update_step(temp, pnode); if(pnode->step > max_step) goto out; } } // length - 1 if(pnode->word_len > 1) { strncpy(temp, word, i); strcpy(temp + i, word + i + 1); update_step(temp, pnode); if(pnode->step > max_step) break; } } // last addition if(pnode->word_len < MAX_LEN) { strcpy(temp, word); temp[i] = 'z' + 1; while(--temp[i] >= 'a') { update_step(temp, pnode); if(pnode->step > max_step) goto out; } } out: if(pnode->step > max_step) max_step = pnode->step; } } printf("%d\n", max_step); return 0; }
void run_game_logic(void){ update_data(); update_step(); update_man(); timer_fired = FALSE; }
//Update Loop void stage::update_loop() { while (!glfwWindowShouldClose(window)) { update_step(); } }