YesNoOk
avatar

Random (Triggers) (Read 43022 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 N00bSaibot & Muramasa RoofTop 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
  • *****
  • Thanks and God bless
    • 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.

-[Все слова это только слова.]-
Re: Random (Triggers)
#7  June 29, 2024, 10:30:52 pm
  • **
  • Expert Noob
  • I am a lover and a fighter!
    • USA
Another fun trick you can do with this trigger is (Random%* = *) (Replace the * with a number. Ex. Random%60 = 15)

Translated into human, it means, generate a random number between 0 and 60 and when the number is 15, activate the trigger.

Example of using it in a state.
[State 1000, Ear Twitch]
type = ChangeAnim
trigger1 = Random%60 = 15
value = 2
;elem = 1
ignorehitpause = 1
persistent = 1

Another example is to use [*,*] instead of a single number. This would mean, generate a random number between 0 and 60 and when the number is any number between * and *, activate the trigger.

Example.
[State 1000, Ear Twitch]
type = ChangeAnim
trigger1 = Random%60 = [0,15]
value = 2
;elem = 1
ignorehitpause = 1
persistent = 1

In this example, the trigger will have around a 25% chance of activating every second. (60 ticks equals 1 second. 15 is 1/4th or 25% of 60. So, every second the trigger will have a 25% chance of activating.)
May you always win every round, both in MUGEN and Life. :)
Last Edit: June 29, 2024, 10:46:56 pm by MarioManX1983