Thursday 30 August 2012

Praise for the Fibonacci Sequence, and other mathematical scaling options


WARNING: This post is heavy on math.


I am here to sing the praises of the Fibonacci sequence. For those unfamiliar with it, here it is in its glory:

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, and so on ad inifitum

It starts with 0 and 1, and then every number thereafter is the sum of the previous two. It can theoretically start with any two numbers, and in many cases it will be more convenient to start with 1 and 2, or even 2 and 3 if the gap between 1 and 2 is too extreme for you.

But what does this sequence have to do with game design?

Game design is inherently about designing systems for your players to enjoy. In order to effectively design systems, you need to know a thing or two about math. For example, I mention in the title the word 'scaling'. For those of you unfamiliar with the term, it refers to the ability for abilities/items/classes/cards/whatever (objects in future) to be effective at all points throughout the game.


Some objects start off incredibly powerful, but lose effectiveness as the game progresses. The most extreme example of this is Dragon Rage from Pokemon. It does 40 damage, regardless of any stats. At low levels, this will kill everything in one hit; at higher levels, everything has enough health that it is pretty much useless.

Other objects start off incredibly underwhelming, but are said to 'scale' incredibly well, making them amazing late game. An example of this is technology in 7 Wonders, whose value is equal to the square of the number of them that you have. Having 4 of a given technology is extremely difficult to beat. This is not to be confused with 'snowball' effects, where an advantage compounds itself in directly competitive games.

If something is always over or under powered throughout the course of the game, scaling is irrelevant, and you probably just need to balance it better.

As a designer, you will inevitably encounter scenarios where you have to scale your objects: the relative strength of all the levels of your object, or of different objects to each other.

This is where math comes in. There are many different curves you can employ when scaling.

There is linear [or incremental]:
1, 2, 3, 4,  5,  6,  7,  8,   etc.
2, 4, 6, 8,  10, 12, 14, 16,  etc.
There is exponential:
1, 4, 9, 16, 25, 36, 49, 64,  etc.
There is geometric:
1, 2, 4, 8,  16, 32, 64, 128, etc.
1, 3, 9, 27, 81, 243, etc.
And then there is the fibonacci sequence:
1, 2, 3, 5,  8,  13, 21,  34,  etc.
There is also Triangular Growth: (for interested parties [(x + x^2) / 2])
1, 3, 6, 10, 15, 21, 28, 36, 45, etc.

The trick to effective scaling is to make each level superior to the last without making the previous completely obsolete (unless you deliberately want to build your game around that, but let's ignore that case for now)

With linear scaling, new levels are not that exciting beyond the second or third, as the fourth is only 33% higher than the third, the fourth to fifth only goes up 20%.
Exponential and Geometric growth grow out of control extremely quickly, so unless there are only a few levels of it, it will dominate and possibly break the late game.
The fibonacci sequence and Triangular growth both provide a reasonable, integral values for scaling your levels.

An example I just noticed (that blew my mind slightly) is in Dominion:
Value of Resource cards (fibonacci)
Copper - 1
Silver - 2
Gold - 3
Platinum - 5

Cost of resource cards (linear)
Copper - 0
Silver - 3
Gold - 6
Platinum - 9

Value of VP Cards (triangular)
Estate - 1
Duchy - 3
Province - 6
Colony - 10

Cost of VP Cards (linear)
Estate - 2
Duchy - 5
Province - 8
Colony - 11

If they ever top Prosperity, you can bet the next VP card (empire?) will cost 14 and be worth 15; and the next resource card (diamond?) will be worth 8 and cost 12. If.

I have also used these scaling options (specifically the fibonacci sequence) to generate stats based on a star ranking system. I rated each object from 1 to 5 on how "relatively" tough or damaging it was, and then scaled that rating using the fibonacci sequence. It results in a diverse range of values, where the difference between each can be felt intuitively, and strategies devised accordingly.

Every system is slightly different, and you should experiment with different scales on your objects, as there are times when each scaling method is appropriate.

In additon, there can even be multidimensional scaling. This is where the end value is the product of two or more different systems of scaling. This is usually only applicable to video games, as the math quickly becomes overwhelming.

The best example and implementation of multidimensional scaling is in Diablo 3. Because of the epic scale and length of Diablo 3, it has an incredible number of dimensions.

For your defence, it has the following:

  • Vitality
  • Health per Vitality
  • Armour (1 - damage reduction)
  • Resistance (1 - damage reduction)
  • Dodge Chance (1 - dodge chance)

The end product of this calculation is referred to as your EHP (equivalent HP) and is the single dimension of your durability.

Each of these values scales individually, resulting in a formula that looks something like this: EHP = HP / ( (1 - (0.1713*ln(Resistance)-0.4353)*(1 - (0.1713*ln(Armour / 10)-0.4353) )
Note that this does not take into account Mob Level, dodge, or block. I am hoping this points out why multidimensional scaling is scarce outside of computers.

Multidimensional scaling is very powerful, as it allows each of its dimensions to have a dramatic impact on the end value, while simultaneously rewarding a well rounded character.


The next time you find yourself wondering how strong to make a Goblin King, compare the relative strengths of his Minions, Shamans, Overlords, and Generals and see if you can find a pattern. The Fibonacci sequence is a very intuitive pattern, and you may have used it without even realizing it (I am not convinced the people behind Dominion did, they probably just went with what values 'felt' right). Knowing when and where to use various scaling methods may just make your job much easier.

But more on that later.

-Colin

No comments:

Post a Comment