varrandom

Started by sgn15, August 20, 2011, 04:36:28 PM

Previous topic - Next topic

sgn15

can i use a set of random numbers (with no particular sequence or mathematical relationships) like 41,67,71, 89 as the possible values of a varrandom (instead of the usual x-y range ) ?

i usually need a set (like 20+) of random big numbers, like in the 1000s or 10000s values

Loona

Not directly, AFAIK, but if there's a set number of them you can probably use embedded ifelse expressions whose result depends on a randomvalue range equal to the amount of set values you intend to use.

Roughly from memory, and based on your example - you mentioned 4 possible values, so let's assume your create a variable v1 that takes a rando value from 1 to 4 - you can use that to assined your desired value based on that using embedded ifelse expressions like this:

v2 = ifelse(v1==1, 41, ifelse(v1==2, 67, ifelse(v1==3, 71, 89)))

Code may be a bit rough as  haven't used this sort of thing in a while.

Алексей

sgn15, What Loona is using there is just pseudo-code, so don't try to use that directly. Loona's concept is 100% correct though:

var(2) = ifelse(var(1)=1, 41, ifelse(var(1)=2, 67, ifelse(var(1)=3, 71, 89)))
would be the correct CNS code in terms of syntax and concept.

-[Все слова это только слова.]-

Cyanide

Wouldn't even particularly bother with a var there.

ifelse(random< 250, 41, ifelse(random < 333, 67, ifelse(random < 500,71,89)))

I probably have my probabilities buggered up there, but the value of random will change each time it's evaluated so the 2 < 250's are totally viable, it's all about giving each value the same chance to occur. So, 25% chance for the first one as it's 1 in 4, 33% chance for the second as it's one in 3 and 50% chance at the end as it's 1 in 2.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.

sgn15

first of all, I didnt expect someone to reply here since i think this thread got buried by the others without a reply. so thanks to you all.

I actually need this random value for something that triggers for gametime = that random value. i need to multiply it by 1000 before equating it to gametime trigger.

so which method is better and more suitable/appropriate for my situation?