hi
can some one give me an example of the prob() proc?
thanks
ID:267675
Aug 13 2003, 2:07 pm
|
|
<code>mob/proc/FlipCoin() if(prob(50)) usr << "Its heads!" else usr << "Its tails!"</code> The prob() proc is basically just a percent chance of something happening. prob(50) is a 50% chance that the result will be true, while prob(25) is a 25% chance. Its a pretty simple concept. |
In response to JackGuy
|
|
thanks again jack
|
In response to Foomer
|
|
thanks foomer
i am trying to use it with an area and i cant get it to work, so there is a prob(25) of getting cought and prob(50) of not getting cought i put the area code here: area first_door Entered() prob(25) usr << "you were not fast enough!" prob(50) usr << "You were lucky" (i had to edit some of it looked confusing because they were long lines) |
In response to Mousie_kebabs
|
|
area That should do it |
In response to JackGuy
|
|
thanks :-D
|
In response to JackGuy
|
|
JackGuy wrote:
> area That should do it I think theres a probleme with this, what I see is realy happening is this: 1/4 of a chance to get 1 and 1/2 of a chance to get 2, that makes out as 33.3% to get 1 and 66.6% to get 2 to form the 100% (I'm pretty sure this is what goes on but im not perfect) |
In response to FranquiBoy
|
|
Yeh, you'd have to use that (im just showing him what to do with the numbers he supplied), but it WOULD work the way i showed, but it would have a runtime error or something, for the chances it doesnt pick one.
|
In response to JackGuy
|
|
pick proc
See also: prob proc Format: pick(Val1,Val2,...) Returns: One of the given values randomly chosen. To make a particular value more or less likely to be chosen, a relative probability may be specified like this: prob(P); Val Or P; Val A value for P of 200 makes it twice as likely as the norm, 50 half as likely, and so on. Example: obj/food verb/eat() usr << pick ( "[usr] eats \a [src].", prob(50) "[usr] devours \a [src].", prob(25) "[usr] wolfs down \a [src]." ) del(src) Also, to pick a value randomly from a list, simply pass the list as the sole argument into pick(). In this case, there is no provision for weighting the probabilities. All items in the list are equally likely. This is straight from the help file and if you look at the exemple, the total odds are 175 that means they dont have to add up to 100 exacly... |
well,put a number ,1 to 100, in the (). and it does Probability of that number percent.
ex:
Chances of 50% you win, 50% you lose.
You can also use prob() in a pick() proc.
That makes it so you have 70% chance of Red, and 30%
chance of Green.