Question regarding a bit of a javascript mystery

Grognard

Villager
Member
Joined
Apr 3, 2019
Messages
26
Reaction score
7
First Language
English
Primarily Uses
RMMV
Hi all,
I have a curiosity I wonder if someone can divine for me:

In RPG Maker MV, I have an event with a conditional set up using 2 variables.
In separate event I define Var 0001 = 20
Then I have Var 0002 = a random integer 0 - 100.
The conditional is set up so that if Var 0001 > Var 0002, the event fails.

I noticed the event was succeeding a lot more often than 20% of the time, so I tested the event with Var 0001 set as 1, and then again set as 99. (Var 0002 remains random).

It seems that when I had Var 0001 = 1, I had a 99% chance of success, and at 99 I had a 1% chance.
It's not a problem, because I just reversed the sign to get the probability I want, I'm just really curious why "If 20 > Random(0-100)" gives me an 80% chance rather than 20%.
 

Doktor_Q

I'm not a real doktor, but I am a real Q
Veteran
Joined
Aug 1, 2016
Messages
875
Reaction score
563
First Language
English
Primarily Uses
RMMV
For clarification, your best bet is to take a screenshot of the eventing in question, including the structure of your if statement, because that sounds more like you have something set up oddly.
 

CaRa_CrAzY

Undefined Custom Title
Veteran
Joined
Jan 19, 2019
Messages
65
Reaction score
27
First Language
Portuguese
Primarily Uses
Other
Are you sure you are comparing "If 20 > Random(0-100)" instead of "If Random(0-100) > 20"?
 

Grognard

Villager
Member
Joined
Apr 3, 2019
Messages
26
Reaction score
7
First Language
English
Primarily Uses
RMMV
Yeah, I'm sure. I was kind of just wondering if there was some quick of js that caused it that I didn't know about. I don't use those variables, but there must be something in the code somewhere. Thanks for the responses~ :)
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
Welcome to randomess and RNG... Unless you're doing an inifitissimal amount of trials, chances/random can work really randomly.

Unless of course its really a case of you actually using the reverse of what you intended to do. So yeah, a screenshot of the events would be good
 
Last edited:

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,117
Reaction score
1,525
First Language
EN
Primarily Uses
RMMZ
In separate event I define Var 0001 = 20
Then I have Var 0002 = a random integer 0 - 100.
The conditional is set up so that if Var 0001 > Var 0002, the event fails.
As written, this means a 20/101 chance of failure, i.e. ~80% chance of success. :kaoswt:

I.e. when var 2 is 0~19 the condition is met and "the event fails".
 

Zeriab

Huggins!
Veteran
Joined
Mar 20, 2012
Messages
1,269
Reaction score
1,423
First Language
English
Primarily Uses
RMXP
When dealing with random numbers I find it helpful doing a bunch of test runs to see if the statistics were correctly setup:
upload_2019-5-5_14-16-52.png
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,035
Messages
1,018,454
Members
137,821
Latest member
Capterson
Top