How I Tuned Enemy Spawn Rates for my Casual Mobile Game Doodle Defender
Defining the Problem and Constraints
The Problem: I needed to create values for enemy spawning rates, as well as values for player upgrades and enemy modifiers (upgrades). These values needed to create a level of challenge appropriate for a casual mobile game, and the variation of challenge should not be too great depending on randomized player upgrades and enemy modifiers.
Constraints:
Players will have a choice of upgrading Fire Rate, Number of Shots, or Shot Speed + Piercing every other wave.
Enemies can randomly upgrade to become faster, to spawn faster and become more numerous, or become more challenging every other wave.
Waves should last between 30 and 45 seconds.
Enemies should spawn at a consistent rate throughout the wave.
Initial firing speed will start at 0.3.
Defining Challenge Metrics
Accuracy: I chose accuracy as my main metric, because it would test the player’s mastery of both of the game’s main mechanics - Aiming and switching colors.
Reaction Time: Reaction time was another metric for challenge, as faster enemies would give the player less time to deal with them before they reached their cannon.
Setting Initial Targets
25% - 33% Accuracy: 25% Accuracy seemed like a good value for the game to have some challenge yet be manageable for less experienced players. The waves should get more challenging as the game goes on, but not by too much, so increasing by half a % per wave seemed appropriate.
> 5 seconds reaction time: 5 seconds should be the upper limit of what we can expect players to accomplish in this game.
Using Constraints to set Initial Values
Using the player’s firing speed and time constraints to set initial spawn rates: With the targets of 30 seconds per wave, 25% accuracy and 0.3seconds firing speed, the ideal initial spawn rates of enemies could be calculated.
Required Shots = (Time Allotted / Firing Speed) * Accuracy
Required shots would reflect the number of total enemies in the wave. Since enemies spawned consistently, dividing the total enemies by the time allotted would give us our initial spawn rate.
However, the last thing to consider is that after enemies are done spawning, the remaining enemies on the screen still have to reach the player. This adds an additional ‘Shot Buffer’ where the player can fire additional shots until the remaining enemies reach them. To calculate this, I used the average time enemies take to reach the player. The final formula looks like this:
Enemy Spawn Rate = Wave Time / ((Wave Time + Average Approach Time) / Firing Speed) * Accuracy)
Note: Due to the enemy chunk system using whole numbers, the final value 25 would be rounded to 24 (3 Chunks * 8 Enemies each chunk)
Addressing Upgrades and Advancement - Using Fire Rate + Enemy Spawn rate to Create Desired Accuracy Targets
Some Basic Principles:
Fire Rate + Enemy spawn rate modifiers were directly opposed: By tuning these values, I could create the desired accuracy metrics.
A generic spawn rate increase would keep difficulty even without spawn rate modifiers: Due to the fact that enemy spawn rate modifiers would not always be present, I wanted the waves to partially keep pace with the player, even if enemy spawn rate modifiers were not selected.
Enemy Spawn Rate modifiers would also include extra enemies per wave: This would be to keep the time of waves relatively consistent.
Using the calculations above, I could change the values until I got close enough to the desired accuracy and time metrics.
Tuning Enemy Move Speed to Reaction Time limits
The enemy’s move speed increases per upgrade could be calibrated so that it was, at maximum, 5 seconds.
Addressing Spread and Pierce Upgrades
Before tuning the Spread and Pierce upgrades, I had to define some more basic principles:
Spread and Pierce upgrades were inherently unreliable: In both cases, the player would be less likely to get full value from each shot. Because of this, the upgrades could be more powerful, and the required accuracy would be lower as a result.
Spread and Pierce upgrades had diminishing returns: The more upgrades of the same type one acquired, the less likely it would be that each shot would get its full value.
Since this was a solo project, I could resolve these systems design issues on my own. However if this were a larger team these would be things I would bring up with the team so the dynamics could be resolved. I would table these issues for now and let playtesting show how these upgrades played experientially.
For the purpose of tuning, I counted spread and pierce both as firing an extra bullet (which may or may not score a hit.) Because of this, any accuracy value 50% of required or lower would be acceptable - when compared to enemy spawn rate modifiers.
Final Results and Synthesis
The final values reflected my target metrics for both accuracy and player reaction time.
However, both of these things would not be tested at once. Due to the random nature of enemy modifiers, different runs could test one or the other to varying degrees.
Considering both the accuracy and reaction time metrics were somewhat high for a casual game, I considered this a desirable dynamic, especially as the random nature of modifiers was designed to create a unique experience each run.
Shot Spread / Pierce had a lower accuracy requirement, but presented its own challenges on aiming to take fullest advantage of the upgrades. I would use playtesting to explore how this challenge manifested.
These are overall systems design dynamics that, were I working on a team, I would bring up to discuss. But for my purposes, these dynamics suited my needs for this title.