Author Topic: Semi-random events based on probability  (Read 2984 times)

ejh1990

  • Posts: 5
  • ( n _ n )
    • View Profile
Semi-random events based on probability
« on: August 26, 2013, 04:56:18 PM »
Hello there. I am trying to get my head around the various logistics of random events and the possibility of using probability. I have found one method, but I am not sure it's really the most efficient way of achieving this. Here's the sort of thing I have going on:



On first loading the game, the game checks for difficulty. This will affect the probability of the next part of the sequence having any noticeable effect. And if the mode is set to easy, the script is terminated altogether.

The set of four variables in the lower-middle to the right are two sets of variable checks and changes for medium and hard difficulties. The medium route returns one pass through the upper section, whereas the hard route forces three passes through it.

The upper section is a simple random yes/no sequence to some mobs spawning. If the result is no, the loop is terminated. If the result is yes, another loop will take over to spawn {x} amount of mobs. The fact that the hard path runs the yes/no sequence three times means that it is more likely for the mobs to spawn on hard.

Like I said, it does seem to be working but is there a more efficient way of utilising probability? I mean, too many of these sequences can't exactly be too great for one's computer, haha. Even if I am not missing anything with regards to a proper probability function, can this sequence be refined in any way?

Thanks in advance for any pointers. :)
« Last Edit: August 26, 2013, 06:06:06 PM by ejh1990 »