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.
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.
1. Game_Player#make_encounter I think
2. Game_Map#encounter step
3. Probably stick that into encounter step
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.
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.