ID:899306   Jul 29 2012, 10:06 pm (See the best response by DarkCampainger.) Code: Problem description:Is there a way to choose random choices, for example (prob doesnt work) ```rand(1,3) if(1) ... if(2) ... if(3) ... ```
 Jul 29 2012, 10:11 pm switch(rand(1,3)) just rand(1,3) doesn't do anything.
 Jul 29 2012, 10:16 pm hmm. I see. It seems to have worked. Thanks!
 Jul 29 2012, 10:21 pm Best response Here's a couple of other options: ```mob/verb/Test() // Using rand() with switch() switch(rand(1,3)) if(1) // 33% chance world<<"A" if(2) // 33% chance world<<"B" if(3) // 33% chance world<<"C" // Using prob() with an if-else chain if(prob(50)) // 50% chance world<<"A" else if(prob(25)) // 12.5% chance (.50*.25) world<<"B" else if(prob(30)) // 3.75% chance (.50*.25*.30) world<<"B" else // 33.75% chance (1.0 - (.5 + .125 + .0375)) world<<"C" // Using pick() with embedded probabilities and switch() switch( pick(20; "A", 45; "B", 35; "C") ) if("A") // 20% chance world<<"A" if("B") // 45% chance world<<"B" if("C") // 35% chance world<<"C" ``` The last one is probably the easiest to configure, but is a little difficult to read. Fixed probabilities in third example so they add up to 100
 Jul 29 2012, 10:24 pm Oh wow, this is perfect! Thank you!
 Jul 29 2012, 10:25 pm And I can read the last one lol. No worries.
 Jul 29 2012, 10:27 pm In response to DarkCampainger Lol, I was gonna go into all of that but found myself not wanting to provide additional information when it was un-needed for what was intended. I'll vote yours up though, you put effort in your response.
 Jul 29 2012, 10:28 pm In response to Chiwy8 Yea, it's not too bad so long as you align the text nicely. Also, I made a quick adjustment to it. The probabilities in pick() should add up to 100 to have the expected outcomes.