|
-
Jul 16th, 2002, 06:52 PM
#1
Thread Starter
Addicted Member
weighted random generation
I've thought on this one for a week or so with no avail, so maybe someone else can help me. Say you have 4 'items', 0-3, and you want the latter items to generated less often then the beginning ones. You could say:
x = rnd * 100
if x > 90 then itemId = 3
else if x > 70 then itemId = 2
else if x > 40 then itemId = 1
else if x >= 0 then itemId = 0
end if
this produces a weighted random generation (10% for #3, 20 % for #2...etc). That's all fine and dandy, but say you want to adjust these as the game progresses. Say, at the beginning id 3 has a 0% chance to be called, but later it has a 20% chance. That requires a readjustment of all the numbers, or a fundamentally different way of having a weighting random generation. The latter part I feel is probably the solution to this problem, but I would like some insight.
thanks,
jmiller
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|