Mobiusco

Regular
Regular
Joined
Sep 1, 2021
Messages
59
Reaction score
10
First Language
English
Primarily Uses
RMMV
Hi there! I am trying to design a minigame using eventing and have been having a little trouble getting it to work.

Basically, the minigame has three flowers, and two bees can spawn out of these flowers. These bees are each connected to a set of three variables, each one designating the bee's spawning position. 1 = left, 2= center, 3 = right. So for example if Bee1 RNG = 1, bee1 will spawn from the left flower, Bee2 RNG = 2 then bee2 will spawn from the center, etc. Once the minigame starts, Bee1 spawns from the center flower and flies upwards, during which the player can either successfully dodge the bee or fail.

This flight period lasts for 80 frames in total, but halfway through (40 frames), a switch is activated which spawns in the second bee, Bee2. After bee2 spawns it begins to fly upwards until it's halfway, as another 40 frames goes by for a total of 80 frames, meaning that Bee1 has now reached the top and finished it's flight period. Once this happens, the variable Bee1 RNG rolls a number at random between 1 and 3, causing bee1 to spawn at a different flower. Once another 40 frames has gone by, Bee2 finishes it's flight period and it's variable, Bee2 RNG, also rolls a random number between 1 and 3 and spawns at a different flower.

This cycle then repeats, theoretically making for a fun minigame where two bee's are spawning out of the flowers with a nice 40 frame offset between them to give the player some time to dodge to the next flower. The problem that I'm encountering is
balancing and optimizing this setup, because currently when I run the minigame like this, the bees tend to spawn out of the same flowers, repeating over and over and over, usually out of the left and right more than the middle. I was wondering if anyone had any suggestions to solving this problem, and maybe a way to make it more optimized because I tend to make all of my events "big and stupid" before learning ways to make them more compact and efficient.

Any help is greatly appreciated, I've included a video example of the minigame in it's current state. It's not like it doesn't "technically" work, it's just definitely gonna be boring if the player can beat the minigame while barely having to move at all lol :)
 

Mac15001900

JavaScript wild sorcerer
Regular
Joined
Aug 7, 2022
Messages
392
Reaction score
524
First Language
English
Primarily Uses
RMMV
Is the video representative of how it usually looks like? I going to talk was about how to our pattern-oversesitive brains actual randomness often feels like patterns, but... 16, 8, 17 are the spawns I counted. Could potentially be bad luck in the video, but if it's like that every time then there might be something weird with the randomness - how are you generating and using your random values?
 
Last edited:

ShadowDragon

Realist
Regular
Joined
Oct 8, 2018
Messages
8,231
Reaction score
3,504
First Language
Dutch
Primarily Uses
RMMV
what is the bees spawing setup?

to balance the game, why not use intervall of 60-90 frames?
than use total bees = > 30, wait frame will be -10 0r -20 depending where you
start, than max speed would be 20-25 frames till its game over or untill 200+ bees
to set it on 10 for the hardest difficulty.

but random 0-2 from flower can be unexspected of very bad luck or alot of luck.
but the default random isn't smooth and there is a tiny plugin to make it a bit more
random than default does which randomize is a bit better, but not much in low numbers.

you have either deal with it or use more flowers (4-5) and test that out.
 

Mac15001900

JavaScript wild sorcerer
Regular
Joined
Aug 7, 2022
Messages
392
Reaction score
524
First Language
English
Primarily Uses
RMMV
but the default random isn't smooth
What do you mean by that? I've just ran a simple test, and getting a random value between 1 and 3 seems to be distributed evenly enough, with just tiny differences that you'd expect from randomness: after I used the command 100,000 times I got 33,476 ones, 33,152 twos and 33,373 threes.
$gv is just an array proxy for $gameVariables
RPGMV_2023-09-25_12-22-05.png
Game_2023-09-25_12-24-13.png
 

ShadowDragon

Realist
Regular
Joined
Oct 8, 2018
Messages
8,231
Reaction score
3,504
First Language
Dutch
Primarily Uses
RMMV
@Mac15001900 if you do a simple random variable, and loop it,
it repeats mostly the same number in a row (3-5x) when using
random 0-4, the chance is lower, but sometimes the same number
comes again, the same issue I get from a random 0-8, sometimes
4x the value is 1 before it change, but in my case it doesn't matter.

if he really want to depend on randomness, than the an array like 0,1,2
can be created, substract 1 when taken, and when empty, automatic
refill and loop again constantly, so each number (21 bees from flower)
would be 7,7,7 every 120 frames so it is more balanced.

there are times if you loop simply low number constantly it would
be around 32,10,45 / 10/45/32 or 45/32/10 for example which isn't
really balanced, its just pain luck or bad luck.

another way for a cleaner random bees is to count from each flower to
make it closer to each number without to much difference so there is
not more than 2 difference from between each flower to make it more
balanced way.
 

Mac15001900

JavaScript wild sorcerer
Regular
Joined
Aug 7, 2022
Messages
392
Reaction score
524
First Language
English
Primarily Uses
RMMV
@Mac15001900 if you do a simple random variable, and loop it,
it repeats mostly the same number in a row (3-5x) when using
random 0-4, the chance is lower, but sometimes the same number
comes again, the same issue I get from a random 0-8, sometimes
4x the value is 1 before it change, but in my case it doesn't matter.
Ah, I though by "not smooth" you meant that it's not uniformly distributed. So what you're describing are simply the consequences of using fully random numbers, right?

OP mentioned that the bees spawn more on the side than the middle, and if that's the case beyond this video then there might actually be something wrong with how they're generating/using the random values.

But if that is just bad luck in the video, then the methods @ShadowDragon mentioned will definitely help make the minigame feel better. I'd also add my idea: when spawning, have a 50% chance to spawn at the player's location, and 50% to spawn randomly (feel free to adjust this percentage until it feels right).
 

Mobiusco

Regular
Regular
Joined
Sep 1, 2021
Messages
59
Reaction score
10
First Language
English
Primarily Uses
RMMV
Ah, I though by "not smooth" you meant that it's not uniformly distributed. So what you're describing are simply the consequences of using fully random numbers, right?

OP mentioned that the bees spawn more on the side than the middle, and if that's the case beyond this video then there might actually be something wrong with how they're generating/using the random values.

But if that is just bad luck in the video, then the methods @ShadowDragon mentioned will definitely help make the minigame feel better. I'd also add my idea: when spawning, have a 50% chance to spawn at the player's location, and 50% to spawn randomly (feel free to adjust this percentage until it feels right).
That 50% to spawn at player location sounds cool, I'll have to try it. Basically my event is setup like this: when the game starts, this parallel event is activated which randomly sets Bee1 RNG to either 1,2, or 3. It then waits 80 frames (the reason I'm using 80 frames is that it takes 80 frames for the bee's to reach the top once they start flying) before repeating. Bee2 has another event just like this to control it's RNG too.
UNTOLD - RPG Maker MV 9_25_2023 6_06_54 PM.pngYou will see however, that there are a bunch of conditional branches. These were my attempt to fix the issue, as it was actually worse before I did this. Before I added the conditional branches, the bee's tended to just spawn out of the same flower like 10 times before spawning out of a different one. Which is weird because what are the chances that it's rolling the same number that many times in a row, it tells me that I'm doing something fundamentally wrong.

Anyway, the branches check to see if Bee1 and Bee2 have spawned on the same flower, and if they have, it stops the event from repeating and it waits for Bee1 to finish it's flight path before rerolling it to any other flower but the current one. I was hoping this would make it so that the bee's could spawn on the same flower once, but then had to spawn on a different one, as I thought that would give it some more challenge. UNTOLD - RPG Maker MV 9_25_2023 6_16_56 PM.png
This is what that looks like, and I thought it would work pretty well, as you can see in the video the bees usually only repeat once then go to a different flower, but sometimes they repeat twice and usually they spawn from the left and right so it all just doesn't feel very good to play at the moment. You can also see that there is a variable labeled as MG Flower Bee1 Left Repeat. This variable has two others like it for the center and right, and there's three more variables just like those for Bee2 as well. These activate if the bee's spawn on the same flower, and it's supposed to reroll the other bee.UNTOLD - RPG Maker MV 9_25_2023 6_32_57 PM.png You can see what that looks like here, where in this example if both bee's spawned on the left flower, and Bee1 has reached the top of it's flight path and then spawns on the center flower, Bee2 will then spawn on the right flower. I was hoping this would make it so that once the bee's repeat one time, they will both spawn on two different flowers ensuring that they will not repeat back to back.

As you can see the whole thing is complicated and weird and just not feeling very fun to play, so any advice as to what I'm doing wrong would be awesome :)
 

Mac15001900

JavaScript wild sorcerer
Regular
Joined
Aug 7, 2022
Messages
392
Reaction score
524
First Language
English
Primarily Uses
RMMV
How certain are you that the path takes 80 frames? Because if it actually takes a bit less, then the RNG value wouldn't sometimes update before the next flight, which could be the cause of more repeats than there should be. Buy otherwise I think the reason was just that this is how randomness works. Take a look at this sequence - does it look random to you? Because it very much is random - I don't even know exactly what you'll see there, but there probably will be a bunch of repeats, since that's statistically almost unavoidable.

When you made the logic for fixing it, you likely made some mistake in it (I can't tell what, since you've only shown parts of it), resulting I the uneven distribution you see now.

My suggestion would be to simply things a lot: in the bee's event, after the move route is finished, roll the RNG (this will ensure its rolled at the right time). Then apply one of the methods mentioned above, e.g. a 50% chance to pick the player's position instead. Or store the previous value before rolling, and if the new and old ones are the same, roll again (if it's the same again leave it be, it's now only a 1/9 chance anyway).
 

rpgLord69

Regular
Regular
Joined
Oct 23, 2021
Messages
688
Reaction score
906
First Language
Finnish
Primarily Uses
RMMZ
I've had an issue with RPG Maker, where generating a random variable between 1-3 sometimes repeated the same value 8+ times (a lot more often than would be statistically probable). And most times it worked normally, so I don't think the problem was with the event setup.
 

JohnDoeNews

AFK TTYL
Regular
Joined
Apr 25, 2017
Messages
2,264
Reaction score
1,781
First Language
Dutch
Primarily Uses
RMMV
Is the video representative of how it usually looks like? I going to talk was about how to our pattern-oversesitive brains actual randomness often feels like patterns, but... 16, 8, 17 are the spawns I counted. Could potentially be bad luck in the video, but if it's like that every time then there might be something weird with the randomness - how are you generating and using your random values?
Those numbers are quite possible when the 1, 2 and 3 both have the same chance of being chosen.

The numbers will get closer together, when not 43 bees were spawn, but 1000 bees. This low number of bees is not nearly enough to conclude one flower has a higher spawn rate than the other.

It is good to do some more testing if you want to be sure, but like this, the numbers wouldn't ring any alarmbells for me.
 

Mac15001900

JavaScript wild sorcerer
Regular
Joined
Aug 7, 2022
Messages
392
Reaction score
524
First Language
English
Primarily Uses
RMMV
I've had an issue with RPG Maker, where generating a random variable between 1-3 sometimes repeated the same value 8+ times (a lot more often than would be statistically probable). And most times it worked normally, so I don't think the problem was with the event setup.
So it usually worked fine but sometimes did things that are unlikely - isn't that just how randomness works? 8+ sequences aren't that rare, you'd expect about one every 2000 attempts. Of course, the probability of something that seems unlikely happening is ever higher.

Those numbers are quite possible when the 1, 2 and 3 both have the same chance of being chosen.

The numbers will get closer together, when not 43 bees were spawn, but 1000 bees. This low number of bees is not nearly enough to conclude one flower has a higher spawn rate than the other.

It is good to do some more testing if you want to be sure, but like this, the numbers wouldn't ring any alarmbells for me.
As I've mentioned before, it could just be bad luck in the video, but since OP specifically mentioned the middle being more rare, I've assumed that the same proportion holds outside of it. Which given how complex their events to make it less random are seems quite possible.
 

rpgLord69

Regular
Regular
Joined
Oct 23, 2021
Messages
688
Reaction score
906
First Language
Finnish
Primarily Uses
RMMZ
So it usually worked fine but sometimes did things that are unlikely - isn't that just how randomness works? 8+ sequences aren't that rare, you'd expect about one every 2000 attempts. Of course, the probability of something that seems unlikely happening is ever higher.

Yes, but not several in less than 50 attempts.
 

Mac15001900

JavaScript wild sorcerer
Regular
Joined
Aug 7, 2022
Messages
392
Reaction score
524
First Language
English
Primarily Uses
RMMV
Yes, but not several in less than 50 attempts.
I can't really troubleshoot an event I can't see, but I can assure you that setting a random variable in MV is not the culprit here, since it just uses Math.random() (unless that was somehow modified by a plugin).
 

rpgLord69

Regular
Regular
Joined
Oct 23, 2021
Messages
688
Reaction score
906
First Language
Finnish
Primarily Uses
RMMZ
Yeah, don't know much about how that random number generation works, but just adding a conditional to that event where it rolled again if the result was the same as the two previous results fixed it.

Anyway, don't mean to derail the thread. Just told my experience. The OP has been given some suggestions already. Like what I said above or ShadowDragon's suggestions.
 

JohnDoeNews

AFK TTYL
Regular
Joined
Apr 25, 2017
Messages
2,264
Reaction score
1,781
First Language
Dutch
Primarily Uses
RMMV
To gain more control of "random" numbers, you could use an array and have vallues in there, like this:

[1,1,1,2,2,2,3,3,3]

If 1 stands for left, 2 for center and 3 for right, then this way, all flowers will be chosen 3 out of 9 times always.

When doing it like this:

[1,1,1,1,2,2,3,3,3,3]

Then left and right will always be used 4 out of 10 times and the center only 2 out of 10.

There is a script call to go with this, but I dont know it from memory. Id have to open my project to copy/paste it, if that is wanted.
 

Mobiusco

Regular
Regular
Joined
Sep 1, 2021
Messages
59
Reaction score
10
First Language
English
Primarily Uses
RMMV
To gain more control of "random" numbers, you could use an array and have vallues in there, like this:

[1,1,1,2,2,2,3,3,3]

If 1 stands for left, 2 for center and 3 for right, then this way, all flowers will be chosen 3 out of 9 times always.

When doing it like this:

[1,1,1,1,2,2,3,3,3,3]

Then left and right will always be used 4 out of 10 times and the center only 2 out of 10.

There is a script call to go with this, but I dont know it from memory. Id have to open my project to copy/paste it, if that is wanted.
I would be very interested in a script like this actually, as I want the minigame to have two levels of difficulty so it would be preferred if I could have more control over these "random" numbers like you say so that the minigame isn't randomly more hard than it should be on it's normal difficulty because of bad RNG.
I can't really troubleshoot an event I can't see, but I can assure you that setting a random variable in MV is not the culprit here, since it just uses Math.random() (unless that was somehow modified by a plugin).
Here is the full event laid out for everyone to help find the best method of accomplishing this:UNTOLD - RPG Maker MV 9_27_2023 6_02_57 AM.png

This is the start of the game, it's the third page of an existing minigame that plays before this one. It's pretty basic, just controls to move the nose if the player uses the arrow keys and checks to see if the bee's Shake variable is on or not.

UNTOLD - RPG Maker MV 9_27_2023 6_03_12 AM.pngUNTOLD - RPG Maker MV 9_27_2023 6_03_36 AM.png

The next thing to explain logically would be the bee's Shake variable. Bee1 and Bee2 both have 3 sets of
variables for that check to see which flower the bee spawns on, and then activates another event.

UNTOLD - RPG Maker MV 9_27_2023 6_04_22 AM.png

That other event in question is this one, a parallel process called Bee1 Shake. This simply spawns Bee1's picture at the flower it's supposed to and then shakes it back and forth a little like seen in the video to give a visual sign that the bee is about to fly up.
There is an identical one of these events but for Bee2.

UNTOLD - RPG Maker MV 9_27_2023 6_04_36 AM.png

Once the event is finished it activates the variable MG Flower Bee Fly Loop =1 which activates another event, the Bee1 Fly Loop.

UNTOLD - RPG Maker MV 9_27_2023 6_22_24 AM.png
UNTOLD - RPG Maker MV 9_27_2023 6_26_57 AM.png

This event also has a parallel process that subtracts from the Y value of Bee1 until it reaches the top of the screen, where it then erases the picture. It also checks if the player gets hit by the bee and marks it, and if the player dodged the bee. Regardless of if the player gets hit or dodges, the switch MG Flower Bee1 RNG ON is turned on. There is also an identical event like this for Bee2.

This switch does two different things. It activates the event MG Flower Bee1 RNG, a parallel process where Bee1 rolls a random number 1 - 3 and then waits 80 frames. There is an identical event for MG Flower Bee2 RNG.


UNTOLD - RPG Maker MV 9_27_2023 6_39_50 AM.png

At the same time as this switch is activated, a switch for Bee2 is activated and it activates an event with another parallel process. This waits 40 frames, then rolls Bee2 RNG to a number between 1 -3.

UNTOLD - RPG Maker MV 9_27_2023 6_42_38 AM.png

Then there is the logic I designed to try and fix the repeating flower issue. I tried to mess with it more but it basically just doesn't work at all how I want it, the whole thing is just slow and the spawning is weird.UNTOLD - RPG Maker MV 9_27_2023 6_52_49 AM.pngUNTOLD - RPG Maker MV 9_27_2023 6_52_59 AM.pngUNTOLD - RPG Maker MV 9_27_2023 6_53_06 AM.pngUNTOLD - RPG Maker MV 9_27_2023 6_53_17 AM.pngUNTOLD - RPG Maker MV 9_27_2023 6_53_26 AM.pngUNTOLD - RPG Maker MV 9_27_2023 6_53_31 AM.png

And the last thing I tried was this check that, if both bee's spawn out of the same flower and then one of them is rerolled, it rolls the other one to a different flower as well.

UNTOLD - RPG Maker MV 9_27_2023 6_57_29 AM.pngUNTOLD - RPG Maker MV 9_27_2023 6_57_34 AM.png
UNTOLD - RPG Maker MV 9_27_2023 6_57_41 AM.pngUNTOLD - RPG Maker MV 9_27_2023 6_58_09 AM.pngUNTOLD - RPG Maker MV 9_27_2023 6_58_15 AM.png


As you can see it's a big clunky mess that doesn't work quite right, as I tend to make things as I learn new ways to make them more simplistic. How would you guys go about fixing this in particular and would that script help? I really appreciate all the help guys, I'm fairly new to the engine.
 

Attachments

  • UNTOLD - RPG Maker MV 9_27_2023 6_04_22 AM.png
    UNTOLD - RPG Maker MV 9_27_2023 6_04_22 AM.png
    186.8 KB · Views: 0

JohnDoeNews

AFK TTYL
Regular
Joined
Apr 25, 2017
Messages
2,264
Reaction score
1,781
First Language
Dutch
Primarily Uses
RMMV
Okay, Ill be at my PC in 20 minutes, then I can show you how to use those arrays. :)

Edit: Sorry, I totally forgot to send you the script call.

In this example, the array is placed in var 115, and then we take 1 value out of the array, and store that value in var 101. (replace 115 and 101 with the variables of your choice.)

1695919457728.png

Here is the script call for copy/paste

Code:
 var scList = $gameVariables.value(115);
 var r = Math.randomInt(scList.length);
 var scId = scList.splice(r, 1)[0];
 $gameVariables.setValue(101, scId);

First we check if there is an array in var 115, with a conditional branch.
If there is no array, or it is empty, we put the array there.

The script call will take 1 value out of the array in a random order, then stores this value in variable 101.

Now 101 can be used in a new conditional branch to decide which flower the bee spawns from.

Each entry will be used once will the array is all empty, then it will restart. So even though the order is random, each flower will be used 3 times before it loops.

If you want flower 1 to be used more frequently then flower 3, just make sure there are more 1's in the arrays than 3's.
 
Last edited:

Mobiusco

Regular
Regular
Joined
Sep 1, 2021
Messages
59
Reaction score
10
First Language
English
Primarily Uses
RMMV
Okay, Ill be at my PC in 20 minutes, then I can show you how to use those arrays. :)

Edit: Sorry, I totally forgot to send you the script call.

In this example, the array is placed in var 115, and then we take 1 value out of the array, and store that value in var 101. (replace 115 and 101 with the variables of your choice.)

View attachment 278243

Here is the script call for copy/paste

Code:
 var scList = $gameVariables.value(115);
 var r = Math.randomInt(scList.length);
 var scId = scList.splice(r, 1)[0];
 $gameVariables.setValue(101, scId);

First we check if there is an array in var 115, with a conditional branch.
If there is no array, or it is empty, we put the array there.

The script call will take 1 value out of the array in a random order, then stores this value in variable 101.

Now 101 can be used in a new conditional branch to decide which flower the bee spawns from.

Each entry will be used once will the array is all empty, then it will restart. So even though the order is random, each flower will be used 3 times before it loops.

If you want flower 1 to be used more frequently then flower 3, just make sure there are more 1's in the arrays than 3's.
Alright so I went ahead and gave this a shot and it works very well.UNTOLD - RPG Maker MV 9_29_2023 2_20_18 AM.png
As you can see I used the script call and set it so that the center (flower 2) is used more then the others, making the whole thing feel more balanced when spawning. I went ahead and made a duplicate of this event for the second bee as well.UNTOLD - RPG Maker MV 9_29_2023 2_20_27 AM.png
Over all this is much better and way more compact then the method I was going with, the only problem I still have is the repeating. While the bees now spawn at a set and balanced frequency, they still tend to spawn from the same flower multiple times. For example, the variable 80 (being used in place of variable 101 in your example) outputs a 1 from the array, which spawns Bee1 at the first flower. The variable 82 for Bee2 then outputs a 1 from it's array as well, and spawns Bee2 at the first flower also. This repeat spawning happens quite often, as you can see in this video I'm including, do you have any suggestions on how to lessen this?
 

JohnDoeNews

AFK TTYL
Regular
Joined
Apr 25, 2017
Messages
2,264
Reaction score
1,781
First Language
Dutch
Primarily Uses
RMMV
When you take a vallue of the array and put it in var 80, then var 69 still shows the vallue for the last bee, right?

All the way on top of the event, make a label called "reroll"

Then right after the scriptcall, make a conditional branch "if var 80 = var 69"

Inside this conditional branch, you put a command "jump to label reroll"

Now, it will go back to the top of the row, if the new bee is the same as the last bee, and will never spawn twice at the same flower in a row.
 

Mobiusco

Regular
Regular
Joined
Sep 1, 2021
Messages
59
Reaction score
10
First Language
English
Primarily Uses
RMMV
When you take a vallue of the array and put it in var 80, then var 69 still shows the vallue for the last bee, right?

All the way on top of the event, make a label called "reroll"

Then right after the scriptcall, make a conditional branch "if var 80 = var 69"

Inside this conditional branch, you put a command "jump to label reroll"

Now, it will go back to the top of the row, if the new bee is the same as the last bee, and will never spawn twice at the same flower in a row.
I went ahead and did this, it works great! The minigame is feeling much better now like I wanted it, I really appreciate you and everyone else's help in this. Now I just gotta work on adding some little finishing tweaks, like maybe that 50/50 chance to spawn on the player's location like Mac15001900 suggested.
 

Latest Threads

Latest Profile Posts

linkedin - Instagram 1 - Instagram 2 [OFF] - Tumblr texts [IN PORTUGUES]
"Understanding others is the greatest life lesson we can learn."
Tfw I was too slow to post in the latest AI art thread :'(

I had a doozy lined up, too
Updated my game's development post with the first video of it in action!


'Milestone Get!' :p
Heh, heh. I've been experimenting with a naughty word detector Common Event and using scripts to check certain strings. I never thought I would see such language in computer code. I would post a screen shot, but it probably wouldn't be appropriate, even with a Spoiler. But it certainly makes me laugh and it works great.

Forum statistics

Threads
136,809
Messages
1,270,280
Members
180,567
Latest member
CaptainAwf
Top