Solved
How to determine action when given a percentage of the probability
Posted on 2004-11-24
Here is some sample code:
#include <stdio.h>
int optionA = 1;
int optionB = 1;
#define percent 75
int main()
{
int x = 0;
for (x = 1; x < 1000; x++)
{
if (UNKNOWN EQUATION)
{
optionA++;
}
else
{
optionB++;
}
}
return 0;
}
I need to be able to give the equation a percentage, in the example above it is 75.
That mean that I need optionA to be incremented with a 75% chance of probability and when it is not incremented, I need optionB to be incremented.
It would be eacy for me to use x=1000 and when x hits 750 that optionB will be incremented. I need it seeded through out the loop.
The main idea here is that each time that the UNKOWN EQUATION is evalueated, no matter if x = 1 or x =10,000, it needs to choose an action based on the percentage of chance given to it.
Any ideas? is this way to simple and I am just missing it?
Thanks for any help!