YesNoOk
avatar

Random (Triggers) (Read 4005 times)

Started by Odb718, September 23, 2015, 06:26:49 am
Share this topic:
Random (Triggers)
#1  September 23, 2015, 06:26:49 am
  • *****
  • Shame on you!
    • USA
Returns a random number between 0 and 999, inclusive.

Format:
    Random
Arguments:
    none
Return type:
    int
Error conditions:
    none

Example:
Code:
trigger1 = Random <= 249
  Triggers if the random number returned is less than or equal to
  249. (This occurs with 25% probability.)

vVv Wheat Stage Released vVv
Re: Random (Triggers)
#2  September 23, 2015, 08:14:33 am
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
Random also generates a new number every single time you call it.
Code:
[State -2]
type = displaytoclipboard
trigger1 = gametime%10 = 0
params = random, random, random
text = "%d %d %d"
Will display 3 different values every 10 ticks with debug mode on (this is technically useless, but proves the point nicely)


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.
Re: Random (Triggers)
#3  September 23, 2015, 09:01:26 am
  • *****
  • Hedgehog Whisperer
  • Red Bull addict
    • Spain
    • xgargoyle.mgbr.net
Random also generates a new number every single time you call it.
Code:
[State -2]
type = displaytoclipboard
trigger1 = gametime%10 = 0
params = random, random, random
text = "%d %d %d"
Will display 3 different values every 10 ticks with debug mode on (this is technically useless, but proves the point nicely)

This is really important when making AI. There are literally tons of characters with horrible AI coding.

Adding multiple "random" triggers to cover different tier AI levels such as random<300 and random=[300,500] in the same state is useless and prone to error as both conditions can be true at the same time.
XGargoyle: Battle posing since 1979
http://xgargoyle.mgbr.net
http://www.pandorabots.com/pandora/talk?botid=e71c0d43fe35093a  <-- Please click that link
http://paypal.me/XGargoyle  <-- Donations welcome!
Re: Random (Triggers)
#4  September 23, 2015, 01:30:57 pm
  • **
    • Brazil
    • thundermugen.com/
Random also generates a new number every single time you call it.
Code:
[State -2]
type = displaytoclipboard
trigger1 = gametime%10 = 0
params = random, random, random
text = "%d %d %d"
Will display 3 different values every 10 ticks with debug mode on (this is technically useless, but proves the point nicely)

This is really important when making AI. There are literally tons of characters with horrible AI coding.

Adding multiple "random" triggers to cover different tier AI levels such as random<300 and random=[300,500] in the same state is useless and prone to error as both conditions can be true at the same time.

I used to make that mistake when coding the AI, now, I use a variable to store the random value and use it for the probabilities, this way, the random trigger is called only once and works way better ^^
Re: Random (Triggers)
#5  April 19, 2016, 07:51:55 pm
  • *****
  • Gaps? Where we're going, we don't need gaps...
    • USA
    • ricepigeon.neocities.org
I recall reading somewhere that the random trigger is slightly bugged in WinMugen, in that it tends to call lower value numbers much more frequently than higher values (I'd imagine something to do with the initial seed). Can anyone clarify/verify this?

Iirc, it was @Cyanide: who posted it initially, so tagging him (unless I'm mistaken, in which case, my apologies)
Last Edit: April 19, 2016, 07:56:11 pm by Ricepigeon
Re: Random (Triggers)
#6  April 19, 2016, 07:59:22 pm
  • ****
  • Target Acquired.
    • Ukraine
    • mugencoder.com
I recall reading somewhere that the random trigger is slightly bugged in WinMugen, in that it tends to call lower value numbers much more frequently than higher values (I'd imagine something to do with the initial seed). Can anyone clarify/verify this?

Iirc, it was @Cyanide: who posted it initially, so tagging him (unless I'm mistaken, in which case, my apologies)

I recall reading the same thing a while back. I don't have the source, but I can back you on the recollection at the very least.

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