Horje
choose random number with weight Code Example
choose random number with weight
int sum_of_weight = 0;
for(int i=0; i<num_choices; i++) {
   sum_of_weight += choice_weight[i];
}
int rnd = random(sum_of_weight);
for(int i=0; i<num_choices; i++) {
  if(rnd < choice_weight[i])
    return i;
  rnd -= choice_weight[i];
}
assert(!"should never get here");




C

Related
yt-project annotate_scale Code Example yt-project annotate_scale Code Example
What should main() return in C? Code Example What should main() return in C? Code Example
OpenDaylight maven settings Code Example OpenDaylight maven settings Code Example
pointer parameter where to put the asterix in C? Code Example pointer parameter where to put the asterix in C? Code Example
como hacer para que una salida en linux aparezca de poco en poco Code Example como hacer para que una salida en linux aparezca de poco en poco Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10