Random Number Difficulty
I''m having problems generating a good random values for the skill stats in a game I''m working on. There are 6 skill stats that can range from 0 to 10, and I want to generate a random value for those stats when generating a character. The problem is I want the numbers to relativitly low.
I guess basiclly what I''m looking for is help coming up with an alorgithim that will do the following:
1)Generate skill points.
2)As it generates skill points decrease the likely hood of generating another skill point.
3)Assign skill points, with prefrence based on how many points a skill currently has.
Any advice?
-----------------------------------------------------
"Fate and Destiny only give you the opportunity the rest you have to do on your own."
Current Design project: Ambitions Slave
I would generate 6 random floats ranging from 0..1.. this can be thought of as a 6-dimensional vector.
Normalize this vector so that the length equals 1.
Then assign skill points by multiplying the respective scalar value by N, the total number of skill points you want him to recieve.
You can play with the distribution of the original floats. If you want a more balanced skill spread, sqrt() the random floats. If you want a less balanced skill spread, sqr() the random floats.
Normalize this vector so that the length equals 1.
Then assign skill points by multiplying the respective scalar value by N, the total number of skill points you want him to recieve.
You can play with the distribution of the original floats. If you want a more balanced skill spread, sqrt() the random floats. If you want a less balanced skill spread, sqr() the random floats.
Get all the probabilities of a given skill being chosen.
for x = 0 to 10
tprob = tprob + skill(x, y)
next x
j = int(rnd() * tprob)
for x = 0 to 10
if j > (skill(x, y) + t) then
skill(x) = snum(x, y)
exit for
end if
next x
This should help
DENC
for x = 0 to 10
tprob = tprob + skill(x, y)
next x
j = int(rnd() * tprob)
for x = 0 to 10
if j > (skill(x, y) + t) then
skill(x) = snum(x, y)
exit for
end if
next x
This should help
DENC
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement