Saturday, 29 October 2011

The Bouncy Stick Problem

Awesomenauts has really fast controls: if you push the stick in a direction, your character immediately faces in that direction. Many games have smoothing animations in between, making the game look more realistic, and adding a bit more weight to the character's movement. However, this also slows down the game a bit and adds some delay to your input, since the character isn't immediately doing what you tell it to. For Awesomenauts we chose to have really quick controls and not do those in-between animations too much.

However, we discovered an interesting problem with reacting so quickly. It turned out that quite often, when a player walked to the right and then let go of the stick, he ended up facing to the left. Even though he was pressing right. Depending on the controller and the way the player handled the stick, this may never happen, or happen 30% of the times. When this happened it was quite annoying, especially when it happened in the shop: the player would accidentally buy a different item than he wanted once in a while.

So we investigated this issue and my colleague Machiel (of Paper Cakes fame) discovered what was happening: whenever you let go of the stick, it bounces back to its centre position. But the spring that causes this bounce is so strong, that the stick actually bounces beyond the centre position for a very short amount of time. This GIF animation shows what I am talking about:

Note that this doesn't only happen on the Playstation's controller: it also happens on the Xbox 360 controller.

So this explains why the player sometimes ends up looking in the wrong direction: for just one frame, the stick bounces back beyond the neutral position. Awesomenauts reacts to input so quickly, that this results in the player immediately turning around. In slower games, this would not be a problem, but in Awesomenauts, it is.

So I made some measurements on the exact output that the stick is giving each frame. In some cases when you let go of the stick, it just springs back to the neutral position. In other cases, it indeed bounces beyond that.

This doesn't always happen, though. So why is that? As you can see in the measurement, the spring back happens extremely quickly, usually within one frame. My guess is that the bounce beyond neutral actually always happens, but is so fast that it often happens in between two frames. So I can't always measure it and thus the game quite often isn't influenced by this bounce.

I tried this a lot of times, and it turns out that the stick can bounce quite extremely. When in the neutral stick position, the stick has position 0. All the way to the left is -1 and all the way to the right equals 1. Now when I let go with the stick all the way to the right (1), I have seen it bounce back to as far as -0.72 before getting back to 0. So that bounce is almost entirely to the left! This greatly depends on the controller, though: it seems like the bounce becomes worse when the controller is older, so apparently it increases with use.

The solution

So, how to solve this? The first thing that comes to mind is to increase the deadzone: ignore small stick input and hope the bounce falls within the deadzone and thus isn't used. However, since I sometimes measured a bounce of up to 0.72, I would have to increase the deadzone to almost the entire range of the stick, which means the game would only react to stick input when the stick is entirely to the right or left. Not cool.

Another solution also seemed reasonable: since the bounce happens for only one frame, an easy solution would be to ignore input that takes only one frame. However, the game cannot know this until one frame later. So to ignore single-frame input, I would have to introduce a one-frame delay in handling the player's controls. That sucks, because it takes away a little bit from the instant controls that make Awesomenauts play so well.

Now if you look at the graphs, you can see that the user never moves the stick all the way to the right in a single frame: he takes several frames to do this, even on 30fps. Users think they react instantly, but in practice they usually take around 0.1 seconds to move the stick in a certain direction. I tried this a lot and even when I tried to move the stick extremely fast, I am still only very rarely able to move the stick all the way to the right in a single frame. During normal use, this never seems to happen.

The evil bounce, however, always happens practically within a single frame. It is much faster than any real user input. So Machiel came up with a solution that uses this. I implemented his solution and it which works great:

When the change in the stick's position is bigger than 1.05, ignore it for one frame. *

This eliminates all the bounces that I have seen. And in my measurements, it practically never ignores or delays actual real player input. When the player moves from neutral to all the way to the right, that is a movement from 0 to 1. That is smaller than 1.05, and thus always used immediately. When the user moves all the way from the left to the right, so from -1 to 1, then he takes several frames for this. So the movement per frame is still less than 1.05, and is thus not ignored.

So, I implemented this, and we have not been able to reproduce the Bouncy Stick Problem in Awesomenauts ever since. Win! :)

* Edit: As Ben suggested in the comments below this post, it is probably best to use stick position 0 when the output is large, since using the previous frame adds some delay to stopping walking.

Sunday, 23 October 2011

What no one told you about the videocard: lagging 1 frame behind

Our new game Awesomenauts is a lot more complex than Swords & Soldiers in every possible way, so we suddenly need to actually have a serious look at performance to get a good framerate on all platforms. Now while trying to optimise things, I found out that I had totally misunderstood an important part of how the videocard works.

I have read several books on programming real-time graphics (including the entire OpenGL Red Book), yet somehow I have never read about this. So when I found out, I spoke to a couple of other experienced graphics programmers, and it turned out most didn't know this either. So I guess quite a few of my readers will find this interesting. For those who already knew about this: why didn't anyone tell me?!?! ;)

So what am I talking about? I always thought that the timing of a frame works like this:

So as soon as you start sending render calls to the videocard, the videocard starts processing them. However, the videocard usually cannot process these calls as fast as it receives them, so when all the calls for a frame have been received, the CPU waits for the videocard to finish, and then proceeds with the next frame.

This scheme is quite nasty, since it contains two periods of waiting: both the GPU and the CPU wait for each other at some point, simply doing nothing in the meanwhile. This wastes performance.

So I have build some timers in Awesomenauts and I saw that indeed the CPU was spending a lot of time waiting for the GPU in calls to things like SDL_GL_SwapBuffers. I tested this in all versions of our engine, so on the Playstation 3, the Xbox 360 and the PC, and this happened on each platform.

So I implemented a multi-threading scheme to do the waiting in a separate thread, so that the next game frame can already be processed while we are still waiting for the GPU to finish the previous frame (this is actually a lot more complex than it sounds, but I will leave out the details for now).

And what happened? NOTHING! PC, PS3, Xbox360: none showed any framerate improvement! Argh! So I asked around to find out what I was doing wrong, and it turned out that the above scheme is entirely wrong. It is simply not how it works. This is how the scheme really works:

So when you call D3DPresent or SDL_GL_SwapBuffers, the time spent there is not spent waiting for the current frame, but waiting for the previous frame. This is actually a really simple and smart solution to the waiting problem I mentioned above. As long as the GPU has more work to do than the CPU, it will never have to wait!

This explains why my optimisation didn't help: as this image shows, the GPU is constantly busy, so improving the framerate of the CPU using multi-threading is totally useless here.

An important thing to mention here is that I am not talking about triple buffering here. Triple buffering is a different subject and this scheme happens regardless of whether triple buffering is turned on or not (although for a good understanding of triple buffering, you would need to take this scheme into account as well).

Note that a side-effect of this scheme is that it introduces some extra input lag: user input (pressing a button to jump, for example) happens in the game state update, and the time between the game state update and the moment when it's results are shown on the screen increases because of this scheme. However, the framerate also increases a lot, so this is definitely a worthwhile trade-off.

Of course, if your game takes more time on the CPU than on the GPU, the GPU will still have to wait:

Now my next question was: does it always work like this on all platforms? It turns out this varies. I asked around, and this is what I learned:

While asking around, I also learned that in some cases on PC, the driver might decide not to wait at all. Someone on the Ogre forums posted here that he had really long input long in his application. It turned out this was because the GPU was a lot more than 1 frame behind, because his CPU had so little work to do. So in his case, the scheme worked like this:

However, I have never seen this happen myself, so I am not sure when this problem would occur. I have heard from a user that Proun sometimes has serious input lag when being run in Wine under Linux. I have not been able to test this myself, but I suspect this is the same problem.

However, this problem is limited by the size of the GPU command buffer: when the GPU is lagging too far behind, the entire buffer will be full of commands, so the CPU will not be able to push in any new ones, forcing the CPU to wait.

This can be solved using fences (an advanced feature of OpenGL and DirectX). Fences allow you to wait until the GPU has reached a certain point. You have to implement this yourself, but it makes absolutely certain that the GPU is never lagging more than 1 frame behind.

To conclude: keep this scheme in mind whenever you try to optimise your game, and be sure to first make sure whether the game is GPU or CPU bound. My fault while optimising Awesomenauts was that I was trying to optimise the CPU, while the bad framerate was being caused by the GPU. Always check your bottlenecks!

PS. My previous blogpost about the sales numbers of Proun resulted in some really painful comments online. I had tried to write a really positive blogpost about how happy I was with Proun's results, but Gamasutra and several other large game sites summarised it simply as "Proun Creator Disappointed With 'Pay What You Want' Results". Some sites and commenters also did some nasty misquotations on how I interpreted the sales data. Lots of people concluded that I am a whiner, and some even did some serious flaming about Proun and me. This is really painful for a game I made for the fun of making it, especially since I am really happy with how Proun did and tried to write a very positive blog post. Interesting how being misquoted can make people online hate me... Anyway, I cannot reach all those people and explain to them how happy I am with the reviews and income I got for Proun, so I guess I can only answer by trying to make more cool games! ^_^

Monday, 10 October 2011

Matisse, Malevich, Warhol, Lichtenstein, Mondriaan, van Dongen

Please ignore that horribly pretentious title, I just couldn't withstand this chance to put my name in that list... ;)

Last week the Stedelijk Museum in Amsterdam had an art game evening, so they put some games in their galleries. The Stedelijk Museum is the biggest modern art museum in The Netherlands and they decided to put Proun in the middle of their throne room, the one with their most important pieces. So there was my Proun, between Matisse, Malevich, Warhol, Lichtenstein and Mondriaan! Awesome! Especially Mondriaan's paintings were an important inspiration for Proun, so it is great to see my game next to six real Mondriaans!

The photo was taken by Richard Boeser, by the way. He is the creator of Ibb & Obb. Ibb & Obb was also there and it is a fantastic game. It hasn't been released yet, but I got a chance to play it and this is one of the most fun coop games I have ever played. Nice! So here is a little bit of marketing for his awesome game, which I believe should come somewhere early 2012. Be sure to turn the sound on to hear the music as well!

Ibb & Obb, by Sparpweed and Codeglue.

Monday, 3 October 2011

Proun sales data revealed: Proun is a big success! Pay What You Want is not!

When I launched Proun three months ago, I promised to release the numbers on how the Pay What You Want model would do. Not that many games are released as Pay What You Want, so a lot of people were curious to see how Proun would do!

This post is a big wall of text. Just skim through the tables and graphs if you feel too lazy to read my explanations and analysis... ;)

It is extremely rare for game developers to release their complete revenue statistics like this. Not many people outside the industry realize that this secrecy that is usually around sales is actually quite problematic. How can you know what the best platform for your game is, if everyone keeps their sales statistics a secret? For small indie companies, knowing where to release your game and for what price is incredibly valuable information! Contracts forbid telling what you sell on XBLA, PSN or Steam, but since Proun is only sold on my own website, I can actually give you this information for Proun!

Before I start with the statistics, though, let me start with something a reviewer wrote. I made Proun purely because I wanted to make something awesome, for the fun of creating games. Obviously, part of that fun is showing the game to people and hearing their reactions. This quote from the Eurogamer review (which scored Proun a 9) is so incredible, knowing that this is what someone thought after playing Proun is enough to make this whole project a tremendous success to me:

"Your role in the proceedings is as a visual conductor, commanding your own hypnosis, sucked into a maelstrom of motion quite unlike anything you've ever experienced."


Incredible that they are really talking about my little game there!

So, let's get to the numbers:

Units sold per price point

Proun was sold as Pay What You Want, so people could set their own price. So what prices did paying folks choose?

The official minimum price to get the bonus track was $2, so the largest group of people chose the minimum. The other peaks are at $5 and $10, the obvious round numbers. But why is $6 also a peak? I checked the complete statistics, and it turns out that these people mostly also chose $5, but the shop system I used added taxes after typing the price, which is why a lot of $5 people ended up paying $6.

Since $10 or $2 is such a big difference in price, the peaks are actually quite different when we look at the total revenue per price point. Now $10 has the biggest peak, and even $20 pops up, despite only a small number of units there:

Finally, the big question: how many people chose not to pay anything? Unlike many other Pay What You Want games, I chose to actually make 'free' an official option on the home page and even offered a Torrent. As you can see here, way more people chose to get Proun for free than to pay:

The $0 price point here is people who used the same store as the paying folks but filled in $0. They didn't have to fill in there Credit Card details as a result. I cannot know the exact number of Torrent downloads, but since every install of the game contacted my server, I do know the total number of installs, so I can estimate how many people got the game from something other than my server.

As you can also see here, 5 people paid $30 or more. That is incredibly generous for this very small game and I thank them for that! The same of course goes for all the other people who paid me something for Proun: thank you very much! The game was also available for free, so this is pure generosity and niceness! Thank you! ^_^


So, let's add these numbers, shall we? Here is a single list of all the general numbers of Proun:

There are quite a few remarkable numbers here. The obvious one is my actual income from the game: €14,105. I count this in euros, because I live in the Netherlands, so that is the kind of money that I can actually spend.

I have not counted how many hours I actually worked on the game, but I estimate if I would have worked on it full-time, it would have taken me 9 months to make Proun. That makes an income of €1567 per month, which is definitely not high, but enough to live from. So if Proun were not made as a hobby project on the side, it would not have killed me. It would not have given me a good buffer for a future project either, though.

However, for a hobby project, this is an enormous amount of money. I already make a living through the games we make at Ronimo Games (like Swords & Soldiers and Awesomenauts), so any money I make through Proun is an extra. Getting €14,105 is one whopping big extra!

From revenue to actual income we go down from $23,043 to $19,947. Where did that money go? There are three groups here: transaction costs (paying with a Credit Card costs a fixed amount of money, for example), taxes (VAT) and the Fastspring fee. Fastspring is the company that manages the actual shop, transactions and downloads for Proun, so obviously they get some money for that as well. All together these make 13% of the revenue. This may sound like a lot, but this is actually very nice. I am not allowed to give any numbers, but let's just say that this is a very good score compared to most other downloadable platforms.

Proun featured a bonus track for those who paid for the game. However, there are quite a few more people who played that track than who paid, so that means that even this Pay What You Want game faced piracy. Not that much, though: 40.78%. This is really low in comparison to the 90% and higher that is supposedly common amongst PC games.

Those who paid, were willing to pay a nice amount though: on average they paid $5.23. That is a price I can totally agree with. Just don't mention that if free players are included, the average price plummets to $0.09...

Sales over time

Next up: is there a so-called long tale for Proun? At a first glance, it would seem like Proun sold all it could in the first few days and stopped after that:

The big drop on day three is because my server went down when so many people were playing Proun. Important lesson learned: always make sure you get a scalable server before launching a game! My new host for the website and highscores ( just scales to a more expensive plan if there is too much traffic. That is way better than the previous host (the really cheap and really lame Hosting2Go), which just closed down the site entirely when it got too much traffic...

Anyway, back to the long tail. The image above seems the move to $0 quickly, but this is actually not true. This graph shows the daily revenue after the initial peak:

As you can see, Proun actually keeps making a little bit of money every day. It seems to have dropped to an average of around $10 per day at the moment, which still makes for $300 per month. That is some nice money for an individual! Also, this blogpost you are reading now will probably generate some renewed interest in Proun, so writing this might generate some extra revenue as well. That alone would be a good reason to write this blogpost... ;)


There is one more money topic that needs discussing, and this money topic is called Arno Landsbergen. Arno made the sound effects for Proun. He also arranged, produced and generally improved the songs I wrote for Proun. Arno wants me to link to his Facebook when I mention him, but I think his solo album is awesome and since it is available online for free, more people should listen to it. So I am going to like to that instead: Dirty Rock (great free MP3 album!).

Arno is the only person besides myself who worked on the game, and obviously he got a slice of the pie as well. When Arno joined me to work on Proun, I had already been working on the game for five years and was not planning to do anything commercial with it. So Arno got on board just for the fun of it. However, we did sign a little contract that said that if Proun was ever going to generate any money, Arno was going to get 7% of it. So of the €14,105 that I made, €987 went to Arno. A nice bonus for something he did without expecting any money from it! :)

Also, Arno did a great job. He surprised me several times by going in a different direction than I expected, like adding lots of keys (pianos, organs, etc.) to the soundtrack. And each time the direction he chose was way better than what I had in mind, so to me this was one very fruitful collaboration!

Now what was this 7% we agreed to based on? As far as I know, in media 8% of the budget is usually spent on sound and music. I have no idea whether this is true, but this is a number I have heard from various sources. Since the songs had already been written by me, but still needed a lot of work, we settled on slightly less: 7%.

Why do I claim Pay What You Want was not a success?

The title of this blogpost sais that Pay What You Want did not do well for Proun. But didn't I make a lot of money with Proun? More than ten thousand euros, isn't that a lot of money? Yes and no. To me personally, Proun did incredibly well. That is a lot of money to make with a side-project, and since I get to keep most of it myself... wow! That's a lot! Thank you, everyone who paid for Proun!

However, over 250,000 people played Proun. Reviewers loved Proun and the game got lots and lots of media attention. Major PC gaming blog Rock Paper Shotgun (gotta love that name) even wrote an extra post saying that even though they already covered Proun before, they just wanted to remind everyone once more that they should really be playing it: Public Service Announcement: Play Proun.

Through Ronimo and through my connections to indie developers all over the world, I know what kind of money a game that achieves that kind of success can make. If I would not have done the Pay What You Want model and would have done a fixed price on Steam instead, I think I may have made 5 to 10 times as much money. That is while even taking into consideration that without the Pay What You Want model, the game would have generated a lot less buzz and much fewer people would have played it. Of course, this is a "What if" scenario, so I can never know for sure. Yet I dare claim that for the amount of success Proun had, it made a very meagre amount of money.

So there you have it: to me personally, Proun is a tremendous success and made an enormous amount of money! But compared to what a game with this kind of success can make, it did pretty badly.

Lessons learned

So, tons of numbers, and what did I learn?

For starters, Pay What You Want is a tremendous marketing tool. The number of sites that wrote about it is incredible, and both gamers and press love it.

The second lesson I learned is that there are a couple of really good services available for managing payments and downloads. Plimus, BMT Micro and Fastspring all offer excelent services in these regards, and their fees are low enough percentages that it is worth it to use them. I used Fastspring and they did a great job. Even when the Proun website went down due to too much traffic, the Fastspring shop and download system always keps functioning. So no one who paid for the game had to wait for the crashed site to get back up to be able to download it!

And then to the big question: why did only 1.76% of the players pay for Proun? This is definitely not because of the quality, since both press and gamers were almost unanimously positive. The amount of content may have been a factor, though: Proun is a very small game, with only five tracks. IGN said it like this in its review:

"Despite being incredibly thin on content, this one-man indie side project is heart-pounding, euphoric, and very addictive."

Incredibly thin on content. That's true. There is no lesson to be learned for me here, though: Proun is a hobby project and making a lot more content on my own would have cost too much time and would have become a boring crunch. I made Proun for the fun of it. If I had known then what I know now, I would still not have made it any larger.

To seduce people to pay for Proun, I added a bonus track. I think the bonus track was a good idea, but I would have done this differently if I had known these numbers at launch.

I think the main reason why so few people chose to pay for Proun is this: the free version did not require a Credit Card transaction and was thus way easier to download.

People are lazy. Systems that remember your payment details and thus don't require you to fill in anything each time you buy something are tremendously successful. Think Amazon, think Steam.

So I think if I had set a minimum price of $1, way more people would have decided to pay a couple of dollars for Proun. Simply because they already had their Credit Card out for the $1 and figured the game was actually worth a bit more. Fewer people would have played Proun, but I think more people would have paid, making Proun a bigger succes financially. Note the emphasis on financially: my main goal was to get as many people as possible to play my game, and the scheme I used was definitely a good choice for that!

So from today on, I am starting a new experiment:

Proun is still Pay What You Want, though, just starting from $1 now. I realise that most of the buzz around Proun has disappeared now, but Proun is still making some money every day, so let's see whether this increases or decreases the revenue! Just like today, I will post the results of this experiment in a couple of months.

Other Pay What You Want games

This post is already way too long, so I am not going to do long comparison with other Pay What You Want games. Instead, I am just going to link to other articles that mention sales numbers of these kinds of models. I only found three similar games, and none of these are a 'regular' game being Pay What You Want at launch. They were either bundles, or short Pay What You Want sales months after launch, so none of these are really similar cases, in my opinion.


So, has Proun been a success? Yes it has! Proun was made as a hobby project, for the fun of making something unique and showing it to the world. It also made me quite a bit of money, but that is not what Proun is about. Proun is about my personal vision of just one way in which games can be more than what they already are. I am glad that the unique and innovative graphical style of Proun really worked for a lot of people. Many games these days look and feel the same, but Proun is part of class of games that does something different. (In this case graphics, but of course gameplay, narrative and sound are equally interesting.)

However, purely financially, I think Proun could have made way more money if it had been sold in a different way. Yet to me personally, it did make a lot of money!

Let me conclude this longest blogpost I have ever written with a quote from Ars Technica's review of Proun. This and other reactions to my game make me feel all warm inside.

"What's striking about Proun is how it makes you feel. The game is epic without being loud, it's sleek without being cold, and it's joyful without being cute. It's a happy game that's not afraid to bloody your nose if you're not paying attention. The tracks feel both expertly designed and effortless."

Thank you.

PS: another, later blogpost with sales data from after this post can be found here:
Proun's sales statistics after removing the free version