For the first topic in programming a diminishing returns formula, I present: logarithms!

## Fast returns early, painfully slow later

Logarithmic diminishing returns feature no upper limit, but degradation tends to be very fast, because logarithms are solving for an exponent. That is, when solving for the log of N in base B, the answer will be the exponent that solves the formula `N = B raised to the power of X`

. This is demonstrated with base-2 logarithms, where log(2) is 1 (`2^1 = 2`

), log(4) is 2 (`2^2 = 4`

), log(8) is 3 (`2^3 = 8`

), etc. Each step in the progression is exponentially larger than the last.

Diminishment happens fast and hard with logarithms. Changing base will change the scale of numbers: a small base such as 1.1 will degrade somewhat slowly until input reaches around 40, while a larger base such as 10 hits that same area of the curve before input has even reached 1. But the curve itself still looks the same.

As with any algorithm, you can always modify input and output in order to fit a given game system, *but the feel of the curve is the same*. This is very important! You shouldn’t get caught up in the details of how to “make” a given algorithm work if its curve simply isn’t right for a particular situation. Changing base is the most common way I’ve seen people try to force the logarthmic system to work, but it only changes what part of the curve they’re using, not the property of the algorithm!

The logarithm formula is heavily based on proportions. If you ask for log(x) and log(2x), the increase in output will be exactly the same as if you ask for log(10x) and then log(20x):

```
irb(main):002:0> Math.log(20) - Math.log(10)
=> 0.693147180559945
irb(main):001:0> Math.log(200) - Math.log(100)
=> 0.693147180559945
```

It doesn’t matter what your base is, this relationship will always hold true. This is due of course to the exponential nature of the equations that a logarithm solves, but in the context of games, it means that a player must put in a lot more every time they want to see the same return, which can really force diversity upon the player:

I have $250,000 a day to invest. I could put it all into oil and get 1243 barrels [

`log(250,000) * 100`

], put it all into environment to clean 1243 tons of pollution, or I could split it 50/50, getting 1174 barrels of oiland1174 tons of pollution cleaned!

## The Danger of Logarithms

The problem with this is that it’s so drastic. In the above example, $125k a day gives you 1174 units of any one resource, but doubling that gives you a boost of less than six percent to production! You can change base, multiply or divide input and output by various amounts, but at some point, pumping very few resources into a problem yields tremendous success (just $250 gets you 552 units of production using the above system) compared to putting in a whole lot more.

In my opinion, a logarithmic system requires great care to be used in a game. In a multiplayer game, I’ve heard it proposed as a way to ensure the little guy survives early on, but as was illustrated, spending 1/1000th the money yields nearly half the production. Balancing the system so much that everybody is on nearly even footing, no matter their resources, isn’t good!

Additionally, the most fun in any game is having to make your own choices. Consider playing a child’s game where you roll a die, move, and possibly take an action forced upon you by the game board or a card. You are learning to follow rules, but you aren’t making choices of any kind. The game is entirely out of your hands – you’re just there to watch and see how probabilities fall. With a logarithmic system imposing choice on the player, it’s not really fun. With an improper diminishing returns system, this situation is the same. The player needs to have a damn good reason to double their investment, and on the surface, gaining 6% more oil just isn’t worth 100% more cost. When the game mechanics create obvious choices to the player, the game isn’t fun.

This isn’t to say such a system cannot work, it’s just that you have to be very careful how **and where** you apply it. A logarithmic dimishing returns system that’s well-thought out and that doesn’t force “choices” upon the player can be very interesting and a lot of fun.

## Where Do They Make Sense?

Single player games that are endless, such as sim-style games, can work well within a logarithmic diminishing returns system, because they have essentially endless resources. Spending $10k a day on pollution control cleans up 4 tons of pollution a day (base-10 log). But due to the nature of environmental control, it’ll cost you a whopping $100k a day to clean up 5 tons. This *seems* unfair to the player, but because of the style of game, and the fact that resources may indeed be totally unlimited at some point, it can work.

Systems that are static and cumulative can also work very well logarithmically. If you pump $5000 into the system on turn 1 and $10000 on turn 2, at turn 3 the output is 9.61 (`log(15000)`

). On Turn 4, it’s still 9.61. If you never donate again, your output will stay at 9.61 forever. Say you’re computing the player’s fame by how many times his gladiators won in the arena (hey, maybe **I** should have done it this way). His first victory will increase fame a great deal, but his tenth? No big deal. Hundredth? Nobody will even notice. In this system, it’s going to be affecting things for sure, but it’s a pretty passive stat and doesn’t really push the player into choosing things differently. He still wants to get in the arena and win no matter how fame is computed. The player’s overall strategy *is not affected*, but his stats are still dealt with in a fairly interesting way.

Along those same lines, realistic knowledge / learning is a great use for logarithms. As you put in more time and effort learning some skill or profession, you find that you get to a novice level in most things almost immediately, and can become skilled in just about anything fairly quickly. But as time goes on, to become a true master of a given skill, it can be incredibly difficult. You could spend 2 months learning to program and be good enough to write mediocre software, but it may take another several **years** of dedicated study to really be a guru. And even then, there’s always more to learn, but the gains you’ll make will be very small compared to the time spent. Realism in games can be argued on both sides, of course, but it’s definitely a situation to use where it makes sense. (Thanks to Frederico for this example)

Logarithms almost always work in subtle systems that have a minor effect on the player. Fame is one example, but other situations can exist where the player’s choices **could** be altered. Perhaps every week, fame goes down by one point, and if it gets too low, the player cannot equip his gladiator in the finest gear. When fame is at 5, the player can access the best stores, but keeping it there from week to week requires the player have a gladiator winning 90 out of 100 battles. This means a huge amount of money goes into new equipment, training, and replacing old or injured gladiators. Is it worth the effort, when keeping fame at 4 takes only a 60% win rate, costing a tenth as much money? There are other things to do in the game with your money, and fame is just one minor system.

I’m not a great game designer, so I’ll stick with these simplistic examples, but I think the idea is clear – diminishing returns via logarithms can be very useful, but must be handled carefully.

Next time I’ll talk about… ROOTS!

Diminishing returns articles on Nerdbucket:

Added a little blurb about how logarithms can be useful when modeling human learning.