I'm looking to change random encounter parameters

menea6587

Villager
Member
Joined
Feb 11, 2014
Messages
26
Reaction score
1
First Language
English
Primarily Uses
It might not take a script because I'm not wanting something ground breaking (hopefully), but I want to know where in the base script I can access the following:

1) the probability density function of random encounters, and how can I change it to another function if preferred

2) the expected value of random encounters i.e. number of steps per encounter

3) the variance of random encounters

If I am unable to do the above without having to add something to Materials, I'd be grateful for a script.
 

EliteKilljoy

Beta Tester, English Proofer, German Translator
Veteran
Joined
Sep 8, 2014
Messages
197
Reaction score
45
First Language
English
Primarily Uses
N/A
I believe you can do all of what you're asking by using the stock RPGM engine, if I'm reading what you want correctly.

Go into a map edit screen and all of those options should be on the right-hand side.
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
1. Game_Player#make_encounter I think


2. Game_Map#encounter step


3. Probably stick that into encounter step
 

menea6587

Villager
Member
Joined
Feb 11, 2014
Messages
26
Reaction score
1
First Language
English
Primarily Uses
1. Game_Player#make_encounter I think

2. Game_Map#encounter step

3. Probably stick that into encounter step
Thanks for the info. Looking at the code, it seems like the game rolls two n-sided dice from 0 to n (n = input in the map properties tab), takes the sum, and adds 1 to it. Then when the player appears, once they have taken this many steps, an encounter occurs. Is that correct?

Fore reference:

Code:
#--------------------------------------------------------------------------  # * Get Encounter Steps  #--------------------------------------------------------------------------  def encounter_step    @map.encounter_step  end
Code:
#--------------------------------------------------------------------------  # * Create Encounter Count  #--------------------------------------------------------------------------  def make_encounter_count    n = $game_map.encounter_step    @encounter_count = rand(n) + rand(n) + 1  end
 
Last edited by a moderator:

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
Not quite.  This gives the average number of steps before the next encounter, not the actual nor the minimum.  That is why you can have the "3 steps and there's a battle" problem.

Here is how I deal with the variance of random encounters

I first create a variable.  For the sake of this example, let us say it will be variable switch #5.

Then in the snippet that you quote for Create Encounter count amend line #195 so that it reads:

@encounter_count = rand(n) + rand(n) + 1 + $game_variables[5]

What this does is to add the amount you set in variable 5 to the encounter count.  This will increase the average by that amount and ensure that many steps have been taken before a battle.

At the very beginning of the game, include this switch in the opening event.  Turn it ON and set it to an appropriate figure.  I set mine to 25.  That ensures that the player will always take at least 25 steps before the next battle.  You now have your minimum, and encounters will tend to happen at around that minimum number.
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
Thanks for the info. Looking at the code, it seems like the game rolls two n-sided dice from 0 to n (n = input in the map properties tab), takes the sum, and adds 1 to it. Then when the player appears, once they have taken this many steps, an encounter occurs. Is that correct?
Pretty much.


Once the count is generated, that's how many steps you can take before an encounter occurs.
 

menea6587

Villager
Member
Joined
Feb 11, 2014
Messages
26
Reaction score
1
First Language
English
Primarily Uses
Not quite.  This gives the average number of steps before the next encounter, not the actual nor the minimum.  That is why you can have the "3 steps and there's a battle" problem.

Here is how I deal with the variance of random encounters

I first create a variable.  For the sake of this example, let us say it will be variable switch #5.

Then in the snippet that you quote for Create Encounter count amend line #195 so that it reads:

@encounter_count = rand(n) + rand(n) + 1 + $game_variables[5]

What this does is to add the amount you set in variable 5 to the encounter count.  This will increase the average by that amount and ensure that many steps have been taken before a battle.

At the very beginning of the game, include this switch in the opening event.  Turn it ON and set it to an appropriate figure.  I set mine to 25.  That ensures that the player will always take at least 25 steps before the next battle.  You now have your minimum, and encounters will tend to happen at around that minimum number.
But that makes no sense. Why would the computer randomly generate an average for the average number of steps? Plus, if you take the expected value of the hard code, you find that the expected value is n+1. Since it only makes sense to count from 0 in computer language, the +1 is just there for translating it into natural numbers.

Hence, the expected value of encounters would be what you entered (+1) in the map properties tab. In any case, going through the process of finding the expected value of the hard code answered my question about its behavior, so this topic is now solved.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
Maybe I wasn't too clear in the thinking behind my suggestion.

My point was that yes, the computer randomly generates an average, but unfortunately the way that RM does it you often end up with what I called the "3 steps and there's a battle" problem.  Although you might set 30 or 40 as the average number of steps in Map Properties, you can still end up with encounters at significantly fewer steps than the one you have specified.  This is one of the reasons why random encounters are so disliked by many players.  The point of the method I suggested is that it prevents encounters at low step counts.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.

Forum statistics

Threads
105,868
Messages
1,017,085
Members
137,583
Latest member
write2dgray
Top