• ### What is your GameDev Story?

#### Archived

This topic is now archived and is closed to further replies.

# Random Number Difficulty

This topic is 5340 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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

##### Share on other sites
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.

##### Share on other sites
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

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 11
• 9
• 38
• 16
• ### Forum Statistics

• Total Topics
634128
• Total Posts
3015693
×