Hey, a friend asked me to create a random age generator between 16 and 65 for his population game. But he would like the adult age from 25 to 35 come up more times then other values out of 1000 returned values.
So imagine a bell curve where they are a greater value in the center and less on the left and right sides. Not many kids or retired people.
My thought for doing this is I sure is not the best way.
Sudo code
So in the loop if it hits the target number it stops and saves it. If it hits the next range once then increment the value and if it hits that second range again then save it and end loop.
If it is on the last loop just save the value.
I am sure this is a very very bad way of doing this but I can't think of another way to start this out?
Thanks.
So imagine a bell curve where they are a greater value in the center and less on the left and right sides. Not many kids or retired people.
My thought for doing this is I sure is not the best way.
Sudo code
Code:
increment = 0
loop rand num 3 times.
if (num is 25-35 and save number adn stop the loop)
if ((num is between 20-24 or num is between 36-50) && increment == 1) stop loop and save number else increment++
if on third loop, just save the value.
So in the loop if it hits the target number it stops and saves it. If it hits the next range once then increment the value and if it hits that second range again then save it and end loop.
If it is on the last loop just save the value.
I am sure this is a very very bad way of doing this but I can't think of another way to start this out?
Thanks.