Each time you take a step, the game randomizes RAM $000A and $0008, with some shifts, and somewhere shifts in $0009 (which is a constantly-changing value). It will then use the value of $000A/000B to generate a random value for $00CE between 0x01 and 0x10. The game will read the tile type Momotarou is standing on (stored at $0278), then read in a table at ROM $3DFD2-3E011, containing the encounter probability for each tile type. If $00CE < less than the probability value, the step counter at RAM $00D6 is decremented. If $00D6 == 0, then the game will start a random encounter. $00D6 is randomized each time Momotarou wins or loses a battle.