playMaker

Author Topic: Send Random Event weighting [SOLVED]  (Read 1621 times)

Breadman

  • Full Member
  • ***
  • Posts: 185
  • Derp
    • View Profile
Send Random Event weighting [SOLVED]
« on: August 21, 2014, 02:37:06 PM »
Welcome to what is probably episode 95 of "Breadman Misses Something Obvious!"

I'm using the "send random event" action to randomly choose between two events. I want event A to happen about 66% of the time, and event B to happen about 33% of the time (give or take).

I've tried "weighting" the events, but I think I'm not understanding the weight system. No matter what I type in for the weights, event B always fires. The only way to prevent this is to weight event B as "0" in which case it never fires (which makes perfect sense).

I've tried all sorts of weight assignments and ratios, and no matter what event B always fires... for example, I've tried these different weight configurations with no luck:

A weight: 1, B weight: .333
A weight: 3, B weight: 1
A weight: 9, B weight: 3
A weight: .6666, B weight: .3333 [thinking maybe they had to add up to 1?]

Maybe someone can help me realize my mistake? :P


« Last Edit: August 21, 2014, 03:35:02 PM by Breadman »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2488
  • Yup.
    • View Profile
    • Cleverous
Re: Send Random Event weighting
« Reply #1 on: August 21, 2014, 03:03:14 PM »
The weight should total 1, but there shouldn't be a problem with mixing it up. Values of .66 and .33 should work fine.

Are you sure nothing else is firing any events? Does B still always fire with weight at zero? Have you tried flipping the event transition targets or making brand new events to see what happens?

Breadman

  • Full Member
  • ***
  • Posts: 185
  • Derp
    • View Profile
Re: Send Random Event weighting
« Reply #2 on: August 21, 2014, 03:18:29 PM »
Hey Lane, thanks for the help.

Knowing they need to total one definitely helps. I got it to work with the ratio I was hoping for by setting A to .666667 and B to .333333 - but I'm noticing something a bit odd.

Event A is the enemy's "attack", and event B is the enemy's "shield". So when the enemy is close enough to the player, he will randomly choose between attack or shield over and over. This is working properly with the weights, but once the enemy starts to shield, he gets "stuck" shielding, it's as though the "send random event" action is not resetting each time its get called. Once "shield" is picked randomly once, it continues to get "randomly selected" each time that state is entered.



I'll keep poking around and trying different methods to isolate the issue, but if you or anyone else is able to think of what I might be doing wrong feel free to let me know!

Breadman

  • Full Member
  • ***
  • Posts: 185
  • Derp
    • View Profile
Re: Send Random Event weighting
« Reply #3 on: August 21, 2014, 03:34:51 PM »
Got it working with a ratio of .7 and .3. Maybe it didn't like the .666667 and .333333? Or maybe just toggling the events back and forth knocked some sense into my FSM :P

krmko

  • Beta Group
  • Hero Member
  • *
  • Posts: 790
    • View Profile
    • Fat Pug Studio
Re: Send Random Event weighting [SOLVED]
« Reply #4 on: February 14, 2018, 03:50:37 AM »
Hi guys, i've got a question on this too, not quite sure how it works.

I get the part when i set one event to .7 (70%) and the other one to .3 (30%), but i have a situation where i dynamically have to change the ratio of some 30+ events. For example, if i ramp up both events by 20%, to .9 and .5, that amounts to 140%.

What will the actual probability be then?