📜 ⬆️ ⬇️

Balance in the games of the genre of Tower Defense (part 1)

This article will discuss the principles of calculating the balance in our game of the genre Tower Defense (TD), which we released in the summer of 2012. for iOS and Android platforms. We will tell you what difficulties and limitations we had to face, what was the course of thoughts of the game designer when choosing one or another solution, and how the final result was obtained.

Game achievements
1. visited the top6 and top7 categories in the US Appstore;
2. ranked top1 categories and top7 overall in RU Appstore;
3. Apple's “letter of happiness”;
4. 425,000 downloads;
5. 5 stars (average rating for all stores);
6. many positive comments;
7. Reviews on the world's leading mobile portals.



Terms
1. Cup (base) - the protected object, to which you can not allow opponents.
2. Creep - the enemy, whose goal: to reach the base. In most cases, can not attack the tower.
3. Tower - a fixed unit installed by a player, usually remotely acting on opponents.
4. Wave - a few opponents moving with small intervals. Usually there is a sufficiently long pause between the waves, during which the player builds / improves towers and assesses the strategic situation on the field.
5. Tile - cell field. In this case, the hex (was chosen as a cell of the field, mainly because of the beautiful visual component of the map created on the basis of them).
6. HP (HP) - health points creeps. That which is taken away when attacking with towers.
')
Approach to calculations
The features of this genre are such that the opponents and units of the player have a fairly simple AI, and the player’s units (towers) cannot move. These factors greatly simplify the creation of the game, however, even in such a fairly narrow framework, you can create an interesting and addictive gameplay.

Consider the boundary conditions:
1. The game is passable, at least with one sequence of player's actions.
2. The player must do something to win. This “something” determines the complexity of the game: how many times per game and at what stages a player must make the right decision (sometimes doing nothing is also the right decision).

On the other hand, balance is, first of all, the utility of all towers used in the game. If you can use only 1-2 types of towers out of 10 available to win at any level, it is logical that this balance leaves much to be desired.
Also, the tactic should depend on the level map and the types of enemies on it, based on which the player can build a strategy for passing.

In our game we are faced with the following limitation: a hexagonal field measuring 14x7 tiles, without a scroll.



Such dimensions of the field impose their limitations, at least in the limit of development. The focus of the game is shifted from “building up the whole map” to “correctly put N towers”. If we draw an analogy on dynamics, instead of building a fortress in our game, the alignment of players before the match.

Base creep and base tower
At the initial stage of the game with a low-filled field, the length of the creep path from the point of appearance to the cup should, on average, be about 20 tiles.
Take creep speed = 0.8 tiles per second (at that speed it looks good visually).

The attack radius of the base tower and the attack speed must be such that the base tower kills a lonely walking creep "in an open field."

A creep going in a straight line gets into the sector of shelling of the tower on 3-3.5 tiles of its way. Then, taking the damage of the base projectile for 10, we can find out the HP unit that will satisfy the condition.



We get 3.25 tiles / 0.8 tiles per second = 4s, during this time the tower will make 8 shots, dealing 80 HP damage.
So, the creep should have no more than 80HP, now it is HP = 75 (in any case, 8 shots, but the player will be offended to see a barely living creep with 5HP, which takes life from the base). Then creeps with a difference in appearance in 4c can be destroyed by 1 tower.

Balance of waves and game economics
1. The income from the previous wave should allow the towers to be completed (or improved) in such an amount that they can beat off the next wave.
2. The player must build new towers every 1-2 waves. If the player does not build towers within 3-4 waves - the balance is bad.
3. The complexity should increase from the beginning of the level to the end, i.e., an excess of resources by the end of the level should not be observed.
4. The difficulty of choosing options for action (where to put the tower? Upgrade the old tower or put a new one?) Should also increase towards the end of the level.
5. At each level, the moment comes when there is no place to build (or upgrade), and this is, in fact, the maximum limit of the level to which it should be completed. In practice, the level should be completed when no more than 60-70% of the places open to buildings are built up.

Options for "degeneration" of the situation
1. The player has nowhere to put the tower. This may be if the towers are too cheap, or the playing field is too small. Since, according to the conditions of the problem, the playing field in the game has dimensions of 14x7 tiles, this point should be paid special attention.
2. A special case follows from the point above: the player’s next action becomes predictable N steps before him. Usually this happens in games where there is a free building in an open field, and the enemies come from 1 point. In this case, the most winning strategy is the construction of the towers "snake". However, in most cases this item depends on the design of individual levels, and not on the basic balance.
3. The unevenness of making money. It is possible that when they reach a certain number of towers, they will destroy any number of creeps, and from one destroyed wave of opponents the player earns so much money that they will be enough for all subsequent waves. Why this is possible and how to deal with it - we will describe below.

Boundary conditions, or how the number of creeps in a wave is calculated
Consider an ideal situation where a wave of creeps moves along a series of towers in a straight line. Calculate how many creeps at what speed of movement and the length of the track can be destroyed by these towers.

Basic Postulates
We take the base creep (fitness) and the base tower (bowler). With a given range of attack, towers of a given creep can simultaneously attack 3-3.25 towers.

The attack speed of the tower is 2 shots per second, the damage is 10 per shot, the HP creep is 75, i.e. it withstands 8 hits. The creep speed is 0.8 tiles per second.

Since creeps move in a wave that has a certain length, a large number of towers can attack at the same time. How much more - depends on the wavelength. Wave extension per tile adds 1 tower to the number of attackers simultaneously.
The length of the "snake" wave can be calculated as N * dt * v, where N is the number of creeps, dt is the delay before the next one, v is the speed of the creep.

We take dt = 0.5c (this is the minimum possible interval between the occurrences of creeps, because, otherwise, it becomes difficult to distinguish individual units in the wave), v = 0.8t / s.

Then, if we know the number of simultaneously attacking towers, we need to calculate how long these towers will attack, for which we divide the path length under the attack by the speed of movement of the creeps.
The product of these quantities will give the total damage that the towers will inflict on this wave.

We make up the inequality, where
• h - unit strength, in strikes for this tower.
• K - the number of shots by the tower per second
• L - the path length of the units under attack,
• v and N - speed and number of creeps, respectively.

For the base tower and the base unit we get:

(3+ N * dt * v) * K * L / v> = N * h;

Variable values:

K = 2; v = 0.8; dt = 0.5; h = 8;

We get the intermediate result:

L * (7.5+ 2 * N * dt)> = 8 * N;

We accept dt = 0.5, and 7.5 round up to 8, because the towers can punch a little more than 3 tiles of the track.

We get:

(8+ N) * L> = 8 * N.

Total, with the length of the path, shot by the towers, more than 8, with any number of creeps they will be destroyed. Thus, we have found a formula that allows us to calculate at what length of the path how many creeps can be launched into a wave.

Moreover, the number of creeps in the wave must be such that the income from their killing allows to build a tower in the number of 1-2 pieces, but does not allow building up the entire field.

About player behavior, building limit
As a rule, the player performs actions with towers in the intervals between the waves of enemies. When the number of waves = 20, the player will produce 20 constructions, each of which may include several parts (built the tower, sold the other, made the upgrade third).

Let us estimate how many towers a player can build on an ordinary field without scrolling. The field size is 14 tiles in length and 6-7 in width. Total, we get: 14 * 6.5 = 91 tiles.

We assume that the entry point of opponents is in the opposite corner from the base of the player. We assume that this point (cell of the field) is one.

If you take the “track” option that the player builds in order to lengthen the path of the enemy’s units (to be under attack longer), then its length will be about 40-45 tiles. To make the enemies move along this “snake”, the player must build at least 30 towers, just the player can build an additional 18 towers (with 43 tiles of the way).



With a path length of 43 and a speed of 0.8 tiles per second, the path of one creep will take about 55 s, the path of the wave - about a minute. Given that the average wave will take 30-40s, then we will find the time of the gaming session: at 20 waves it will be about 10-15 minutes (without acceleration) at difficult levels. However, as practice has shown, it is possible to create a rich and dramatic level with a smaller number of waves - about 10.

Another advantage of a fairly small number of waves, and, as a result, a not very long time to pass the level - the player does not lose enthusiasm, having lost a couple of times at the end of the level, and starts the level again, instead of leaving the game.

It is clear that no wave of base creeps will be able to pass this path, completely built up with towers (I remind you that with a path length of more than 8, base creeps do not reach the base with any number of enemies in the wave). Then, let's try to calculate which HP should have creeps, a wave of which at least partially can reach the base.

Let's return to the previous formula:

(8+ N) * L> = h * N.

With a path length of 40, HP creeps, so that they are guaranteed not to kill the towers for any number of enemies in a wave, must be at least 40 * 10 = 400 (this is 5 times more than the base creep, that is, the creep must withstand 40 strikes of the base tower) :

(8+ N) * 40> = h * N
320+ 40N> = h * N.

When h = 50, we get:

320> = 10 * N, N <= 32.

With such N (the number of creeps in the wave) towers will not be able to destroy all creeps.

Taking into account that the calculation was made for base towers with a price of 60, it is possible to calculate how much money the player should earn (plus the starting balance of money) in order to build such a “snake” (remember, for such a snake you need to build 30 towers).

Total, we get 1800 coins for 20 waves.

Calculate the first waves.
Consider the beginning of the level. Suppose the player had enough starting money to install 3 towers (total path length under shelling = 4, on average, with a total length under shelling 6, but 3 towers simultaneously beat only part of the path), then the number of creeps in the first wave should be with dt = 0.5c:

(8+ N) * 4> = 8 * N
32> 4N, N <8.

So, then every creep should bring at least 5-6 coins so that the money from the first wave would be enough to buy a base tower or upgrade.

Therefore, knowing how much money the player will have at the end of the first wave, you can calculate the total "deadly power" of the towers on the 2nd wave, which means to estimate the number of creeps in the 2nd wave in the same way. Of course, both towers and enemies should be of more than one kind, but we will tell about their configuration in the next article Balance in games of the Tower Defense genre (part 2)

Source: https://habr.com/ru/post/173913/


All Articles