How would I take and make it so a random variable in a random code problem could be multiple things?
Example..
var/randomfish=rand(1,32)
if(randomfish==1)
Like, that - randomfish==1.. How could I make it so that random would be more likely than the others, so I could take the 1 and add multiple numbers in a sense so that that specific fish would be more common in the fishing code than the others. (The 32 is a much higher number than the total of fish)
ID:161882
Mar 19 2008, 5:49 pm
|
|
In response to Garthor
|
|
Garthor wrote:
Though, if you can, using pick() might be a better choice: Except pick() doesn't work that way, you cannot set different probabilities for each item in a list with it, if you use a list every item has the same chance. You can however make a new proc to do such a thing. You can find Lummox' pickweight() proc by searching. |
In response to Kaioken
|
|
Not true. At least, what Garthor suggested with pick isn't impossible at all.
mob You'd replace the text strings with paths, obviously, but I tested this and it adheres to the values very well. The format is prob(P) or just P; value. |
In response to Garthor
|
|
Thanks so much. I went with the first one, it worked like a charm for what I needed.
Big help, thanks guys. |
In response to Devourer Of Souls
|
|
You're right, I messed up the formatting. http://www.byond.com/docs/ref/
|
In response to Devourer Of Souls
|
|
Devourer Of Souls wrote:
Not true. Ah, I see. But that kinda depends on what you're referring to. I possibly got confused myself and though Garthor was referring to something like a pickweight() proc with the default pick(), since Garthor was using the associative list format but apparently forgot to encase it in the list() proc, or so it seemed. So I corrected that you cannot pass an associative list to the default pick() and have custom probabilities. I stand corrected about what you said about pick()'s alternative format, since it is usable in this topic's situation. Note that it isn't as flexible as a pickweight() proc, though. |
Though, if you can, using pick() might be a better choice: