Month: June 2011

Printing Generic C++ Containers

Always wanted a simple utility function to print our an arbitrary STL container? Well, so long as your container type support directional iterators… this method I wrote will work perfectly! Its a great example for why templates are awesome

And now how to use the function:

Compiling Qt with Visual Studio

So your awesome project that you’re developing with Visual Studio, and you want to use Trolltech’s Qt library? Luckily Trolltech provides an awesome Visual Studio plugin that does almost everything Qt creator does (minus Intellisense support for slots). The bad news is that Trolltech doesn’t directly tell you how to go about doing this:

  1. Download and install the Qt for Visual Studio plugin.
  2. Download the source code for Qt 4.7
  3. Start the Visual Studio 2010 Command Prompt ( Microsoft Visual Studio 2010 -> Visual Studio Tools -> Visual Studio Command Prompt)
  4. Navigate to the directory with your downloaded Qt SDK
  5. Run the configure program like so: “configure -platform win32-msvc2010 -debug-and-release -static -no-gif -no-qt3support -no-dbus -no-phonon-backend”
  6. Wait ten or so minutes for configure to finish
  7. Now run nmake. And make dinner, because this will take a very long time
  8. You have Qt ready to go! Yay!

The configure parameters I provide will configure Visual Studio to build the vast majority of Qt. There’s a lot of extra options you can explore if you desire more control – for instance, you can enable exception support.

Have fun!

On Randomness

So, here’s an interesting problem that I’ve been thinking about. Most (if not all) games make very heavy use of random values to determine outcomes and results.

The interesting thing about this though is the idea of luck, or more specifically runs of bad luck (aka incurring the wrath RNG God) where you consistently do not realize the outcome you wish. Ask your average RPG player – what’s more frustrating then attacking a low level spider and missing the next five attacks only to have the spider slay you? Impossible? Not at all. Improbable? Of course. Another infuriating example of this comes in with loot drops. Many bosses drop unique or rare types of loot that people want to collect, and expecting to collect these items can be an exercise in frustration. A 25% drop in no way means that you will have the item within four kills, rather you will need to kill the boss 14 times before you have a 98% chance of collecting said item.

So basically, pure random rolls stink. Over time, the bad runs average out with the good runs, so its not like these situations happen all the time. However it’s human nature to remember the bad runs, and sometimes enough improbable bad strings of luck is enough to make the player quit your game entirely. Sure, it might be _fair_… but who plays a game to die to a lowly spider just because of bad luck? People play games because they want GOOD luck.

So how do we fix this? Well this is what I’ve been thinking about for the past few days. Instead of a pure random number generator, I want a “nice” random number generator that somehow ensures you will get a desired outcome sooner rather than later. Essentially, we want to break up runs of “bad results” with good results in between. The best answer I’ve found so far is the concept of a “grab bag”, which is array of pick results that is shuffled.

I’ll go over this concept more in my next post at some point in the future, and some of interesting properties it brings up. The results are more “balanced”, but does it ruin the concept of a game? Stick around!

(I’m going to try writing more entries to practice my writing abilities, and also to share my thoughts with everyone else on game programming and design. Please share criticism or suggestions with me!)