IIRC it was all random. Although I've never had battles four steps in a row, or lack of battles for an extended amount of time.
What you could do, if you thought it was a big enough problem, is have a variable for counting steps until next 'random battle' by doing a randInt(5,50 or something when one battle ends, then decrement the var when sub(Str,your_position,1)=grass.
Get all that?
On a semi-related note, the new D/P have an official American release date: April 22 2007.