Wednesday, December 15, 2010

On Probability


Nearly everyone has a poor grasp of probability, including many professional game creators (and I very much include myself in this). I talked about procedurally generated content in games with some other designers tonight, and obviously randomness factors into that. And of course, chance in general plays a big part in many games. So rather than something more abstract, or about some game I've been playing lately, this is going to be a brief primer on the mathematics of probability. It's more that writing it will hopefully lodge it more firmly in my grey matter, but if anyone else gets something out of this, that's great too.

The difficulty in really understanding probability is compounded by at least two factors. One, pure randomness almost never exists in nature, so having an event so controlled and discrete as to have the probability of its outcomes even be calculable is tremendously rare. Even devices we manufacture to be random turn out to be quite biased (e.g. the rounded corners of Warhammer-style dice make them almost twice as likely to roll a 1).

Two, humans are really good at pattern matching. Honestly, too good. Our brains are wired to seek out patterns, even when they aren't there. Appropriately enough, one manifestation of this is called the Gambler's Fallacy. Basically this describes the belief that after a "streak" of one particular outcome, another outcome is more likely. So if you've been tossing a fair coin and it's come up heads twenty times in a row, tails is "due" to come up. But of course the coin has no statefulness or memory of past events. The likelihood of tails versus the 21st heads is the same as it always was, 50/50.

The reasoning behind most probabilistic math is actually quite simple. It's simply a matter of enumerating all the possible outcomes and either counting the ones you want or discarding the ones you don't. Using the perennial example then, what's the probability of a six rolling a d6 once? Obviously, 1/6. What's the probability of rolling two sixes in a row? It's just the likelihood of the first event (1/6) being following by the second event (also 1/6), or 1/36.

Other possibilities are slightly more complicated to explain, so I'll just mention one more common case and leave the rest to one of countless Internet explanations better diagrammed than this. Often we care about the likelihood of some event occurring at least once in some set number of tries. So what's the probability of at least one six in two die rolls? Well, the probability of not getting a six on the first is 5/6 and the possibility of that also being followed by a non-six is also 5/6. Multiplying these together we get the probability of no sixes occurring, so subtracting that from 1 gives the probability of at least once six. Probability = 1 - (5/6 * 5/6), or about 30.5%.

Note that it is not 1/6 * 2, which would be 33.3%. Seems like a small difference, but imagine this relatively mundane situation. Creating some RPG, our wayward designer sets up a quest where player must kill Greyfang Gnolls to retrieve a Stolen Senatorial Standard. Any gnoll has a 1/3 chance of dropping the standard. Thinking it would be appropriate to add "twice that many" gnolls, our designer puts 6 gnolls in an area, thinking almost all the players will get the standard by the time the sixth gnoll is dead. But what's the actual probability of the standard dropping after killing six gnolls?

As above, the probability of the standard not dropping is 2/3. Multiply that by itself six times for all the gnolls and subtract it from 1, or p(standard drop) = 1 - ( (2/3) ^ 6) = ~91.2%. That seems good, except imagine if our designer's game is successful, netting one million players. Of them, about 88,000 will kill all the gnolls and never receive the standard. To them, this will almost certainly be indistinguishable from a bug, or at best, a misleading quest description.

That is exactly the danger of probability. Something with a high probability seems like "it should occur" except for some amount of people, it won't. Setting an event to occur at a very low probability still means some fraction of players will still experience it. We want probability to behave as if we're setting bounds on the likelihood of something occurring, but that's not how straight random events work. They're stateless (again, see the Gambler's Fallacy), which means the likelihood of all sequences of outcomes is exactly the same. You're as likely to get 20 heads in a row as you are 20 tails.

This is nothing new either. Old Dungeons & Dragons random loot tables would often include one or two absurdly overpowered items in the far upper reaches of the chart, acting as if putting the "Ring of Three Wishes" at 1/1000 means it's rare. For someone rolling on that table once, getting the Ring of Three Wishes is just as likely as any other thing on the chart. So one out of a thousand gaming groups would have to deal with an extremely unbalancing item. Given that hundreds of thousands of people might be rolling on the table dozens of times, it's far more common to occur that you might think just looking at the "1/1000" likelihood.

Even some very, very smart digital game developers have made this mistake. Team Fortress 2 had its random loot system revamped earlier this year, as they detail here. The key line: "Previously, we rolled randomly at intervals to see if you got an item drop. Now we roll to determine when your next item drop will occur." They changed their algorithm to provide what they really wanted in the first place, item drops to occur randomly within some bounds.

On DeathSpank, we initially made the same mistake. Loot drops were simply a flat random chance, but that meant a player was as likely to kill 50 greems and get a loot drop from every one as they were to kill 50 greems and never get a single piece of loot. (This isn't quite true, there were other factors in determining when to drop loot, but it was still a very real problem)

The solution I proposed and implemented was to change the model of loot drops from being basically a roll of the dice ("boxcars means you get loot") to drawing from a deck of cards ("ace of spades means you get loot"). The difference being the cards don't go back into the deck after they're drawn. You don't know when you're going to get the ace of spades, but sometime in the next 52 draws it's guaranteed. The most often you'll see loot is back-to-back (last card in one deck, first card after the shuffle) but in this case, there will be a 51 card gulf on each side. And in the inverse situation, the longest you'll go between loot drops is 102 cards.

Again, this is a gross simplification, but it's basically the chance we (and by the sound of it, Valve) made to make our random distribution of loot match the player's expectations. And that's really the heart of it- only on the rarest of occasions do we actually want true randomness. Possessing at least a basic understanding of probability is an important skill for almost anyone interested in creating games. Used correctly, probability can be a fantastic tool but used incorrectly, it can create some seriously unsatisfying experiences. Even with something as mundane as dice, things are not always what they seem. Many suddenly penniless Las Vegas visitors can attest to that.

Labels: , ,

Sunday, October 24, 2010

From 'Spank to Shank


If you happened to miss my announcement on Twitter, Friday was my last day at Hothead Games. It was a very amicable parting and I'm definitely going to miss my Hothead comrades. But they've got a tremendous amount of talent (believe me, Swarm is already fantastic and is only going to get better between now and its release early next year), so I think they're going to be alright.

What lured me away from the awesomeness of Hothead? I had accepted a position as Technical Designer at Klei Entertainment! For those unfamiliar, Klei most recently released Shank. If you've been reading this blog for any amount of time, you've noticed I spend a lot of time thinking about design and creating novel experiences. I accepted the position with Klei because doing that is basically my mandate and I'll be leveraging my technical background to do so effectively.

This isn't the first time I've worked for Klei either. I actually worked for them in late '08 to early '09. But Klei has changed a lot as an organization since I was last there. When I was there initially, they were working on Sugar Rush, a free-to-play brawler for Nexon (the closure of Nexon's Vancouver studio is what precipitated having to leave Klei for Hothead originally). Now they've just released a digitally distributed game based on original IP they created and own. And the plan is to keep doing that. This is exactly the space I want to work in and the kind of organization I want to work with. I'm really excited about coming back to Klei and the kinds of things we'll be able to do together.

Coincidentally, exactly two years ago, I was doing this exact same thing: taking a week off to play the newest Fallout before starting a job at Klei. I think I'll probably make some time to make a game and do some reading, but I'd be lying if I said I wasn't going to see much of the Mojave Wasteland this week. I haven't had any proper time off since my honeymoon in August '09, so I'm looking forward to a week of fewer obligations.

Finally, both DeathSpank and Shank are coming out on Steam tomorrow! If you haven't played either, there's a 15% off Steam package deal for both that should still be live if you're reading this early enough. I obviously can't speak for Shank, but we put a *lot* of work (way more than I thought we'd need to, honestly) into making the PC version of DeathSpank feel good. Genuinely native, not like some knock-off port. And the game looks damn good too, in my rather bias opinion. The pallet really pops at PC monitor resolution and the characters/environments scale up real nicely. I'm glad we can finally show off our awesome artist's work at the resolution it deserves. That's enough shilling (although it's not like I get any kickbacks now), but if you haven't had a chance to play DeathSpank yet, this is the version I'd recommend.

Thanks again to anyone who has taken the time to read this and I'm looking forward to putting some of these mad ramblings into action at Klei.

Labels: , ,

Wednesday, September 22, 2010

Let's Get Spankier!


DeathSpank: Thongs of Virtue has been released!

Just a scant two months after the release of DeathSpank, the second half of our mad tale is available now. You can get the XBLA version (or just download the demo) here and the PSN version from the store directly on your PS3. It's 1200 points and $14.99 USD respectively, same as DeathSpank. But given that Thongs of Virtue is a longer, larger game, that's really like a discount!

Additionally, as a thank you to everyone that's supported DeathSpank and Hothead, for the first week of Thongs of Virtue's release, we'll be giving away not one, but two DLC packs. The first is high-level dungeon that not only raises the level cap, but also features one of the most obscure (yet amazing) visual puns we've done with an enemy. See if you can spot it! The second DLC pack adds a third sidekick Tannko, to go along with Sparkles the Wizard and Steve (who himself is new to Thongs of Virtue). Without question, Tannko was a crazy thing to do, but crazy in a good way, I think.

In unrelated news, Michael Abbott was mind enough to invite me to be on his podcast once again. This time, I was joined by David Carlton and Matthew Burns, where we discussed PAX, GDC and various other "gatherings of the tribe." Great talking to those guys and I'd highly recommend listening to part 1 and part 2 as well, where other guests discuss those events from a journalist/critic perspective.

So if you liked DeathSpank, there's even more to like in Thongs of Virtue. I think I prefer it to the first and my favourite thing in all of DeathSpank is at the very end of the second game (how's that for a tease?). And if you never got around to DeathSpank, there's no better time than now to check out the demo! As always, I'd be delighted to hear what any of you think about DeathSpank: Thongs of Virtue. Now go out there and make the downtrodden undowntroddenened!

Labels: , ,

Monday, September 20, 2010

DeathSpank Reflections ... of Justice!


I had been playing DeathSpank on and off since it was released, but since DeathSpank: Thongs of Virtue comes out next week (!), I wanted to finish it before then. I completed it with a full 100% yesterday and figured I could share some thoughts. Of course, this is all just personal opinion, not official Hothead stance, etc. There's some spoiler-y stuff in here, so if you haven't played/finished the game, consider yourself warned. No particular order for any of this, just as the thoughts fell out of my thinking hole.

Our artists really went all out with the armour sets. Nearly all of them look fantastic and/or hilarious, so it's a little bit of a shame we didn't provide more incentive to collect all five pieces. I only collected one full set throughout the entire time (the Epic Awesomeness set depicted above, actually). I think this is just where the Diablo-esque loot mentality bumps up against our slightly more structured loot distribution. With the armour sets in Diablo II and World of Warcraft, the heavy proceduralism makes getting a full set by yourself unlikely. But by trading with others, a full set isn't out of reach. Even in Torchlight, the treasure chest you share between characters allows you to collect set items through multiple playthroughs. Our loot is distributed more regularly, which works better for the game as a whole, but it means you likely won't get all the pieces of a set unless you're trying quite hard. And it's a shame, because some of those sets do look great when you've got all the pieces together.

I really like Lord Von Prong's Museum, more than I remembered. It's a solid little area, it's dressed really well (courtesy of Matt, one of our artists, I believe), Ick & Badger imply a history with DeathSpank and they're pretty funny, and the little opera clips are great (can't remember who wrote all those names, maybe Deirdra?). The puzzle in here is good, I think, but it's short and then that's it. This area was added a bit later on, so I understand why it doesn't get a lot of screentime, but it really is a cool spot. Wish we could have fleshed it out a little more and been able to give the player more reason to take a look around.

Similarly, the murals telling Lord Von Prong's story on the walk up to his castle are great. They were later additions as well, so their presentation isn't as strong as it maybe could be. I only say that because the player could totally breeze by them, caught up in combat, and not take the time to stop and look. Hopefully most folks did, because I think they're pretty hilarious and look quite good. They help flesh out Von Prong a bit without a bunch of heavy-handed exposition, plus having giant autobiographical murals in your own castle is totally something a megalomaniacal tyrant would do.

The Wretched Man (the one that gives you multiple culinary quests) has a nice arc with his quests. He starts out pathetic and begging for stones and ends up practically demanding rare delicacies. Some other NPCs kind of have this arc too, but his just seemed to work for me (and I really like his voice acting). His quest just sort of ends though, wish it had a little more of a wrap to it.

Heh, the Sword of the Spinning Blade is really good. I don't think it's too good in a dominant strategy kind of way, but I did find myself using it a lot. One thing we could have done is have DeathSpank get a "dizzy" debuff for a few seconds after using it, where your controls would be all crazy. Then you'd want to be careful about using it if you knew there would still be guys standing after it was done. Bit of a risk/reward decision might have made it more interesting.

The distribution of end game enemies is a little odd. There's a lot of level 16-17 guys, and in several pretty distant locations, but not too many above that. We probably could have had that be a little more even. It's tricky though, because the player's level (and therefore, challenge) can differ a lot. Someone doing all the side quests, like me, is much better equipped than someone doing only the vital quests necessary to progress. Yet, the game should be about as fun for both people. And providing that range where it's not too easy for one or impossible for the other is actually quite hard. All things considered, I think we pulled that off well. This is more just an observation that the spreadsheet underneath all RPGs really does make them very challenging games to make. I don't think it's the right solution, but I do appreciate why Oblivion just made everything level up with you.

And I do really like that the only level 20 monsters in the game are the unicorns and Von Prong.

I'm glad we made the Prongenator mandatory. Initially you could defeat Von Prong without it, but those quests are just too good to pass up. Freen has some of the best dialog in the whole game and making it optional just doesn't seem right. And even though I've seen it several times, I still find that Prongenator cutscene hilarious.

In general, Klei did a fantastic job with all the cutscenes. The papercraft/stick puppet look is great. And some of the characterization/humour in the cutscenes works really well. Hats off to those guys for being awesome.

God damn, the Pip Village is hard. And I programmed those guys' bloody AI too, so I've got no one to blame but myself. It's probably just because I went there more or less straight away after getting my gear back in Pluckmuckel, which probably wasn't ideal. It was fun having guys that were seriously big and scary, but maybe we accomplished that goal a little too well.

The Sea of Bones at the entrance to the graveyard is great. Having an area where a *ton* of weak-ish guys spawn provides an interesting challenge and a great frantic feel. Even though I knew it was coming, it was still a pretty serious, "Oh crap, oh crap, oh CRAP!" moment.

The thong stuff is a actually kind of subtle. We all know the story and what's going on behind the scenes, but looking at it through the eyes of someone that doesn't, the reveal of Von Prong's magical thong at the end is kind of a surprise. As we mentioned at PAX, the thongs play a very large part in Thongs of Virtue (hence the name). There's just enough of a tease in DeathSpank that hopefully folks were curious about it. And I also need something to justify the hundreds of pairs of women's underwear I gave away at the show.

All in all, I'm quite happy with the crazy little game we made. Of course, you'll always see the little things you wish you had the time to make better (I'm sure almost all game developers, or creative people in general, feel this way). I think we were able to address quite a few of the things above in Thongs of Virtue as well. But on balance, given all the constraints we had, I'm proud of what we pulled off. For those of you that played it, I hope you agree and are slavering uncontrollably for more DeathSpank in two days. And if you haven't, the demos are up on XBLA and PSN. Either way, I'm always curious to hear from folks about their dispensation of Justice.

Labels:

Wednesday, July 14, 2010

Time to Get Spanked!


DeathSpank has been released!

You can get the XBLA version here and the PSN game page is here (unfortunately, you can only get the PSN version directly on your PS3, boo!). It's 1200 points and $14.99 USD respectively. In terms of PPUH (price per unit of hilarity), you won't find a cheaper source of mirth, I guarantee it. After spending over a year and a half on this project, it's fantastic for folks to finally get a chance to play it.

Additionally, this is my 100th blog post! An auspicious anniversary indeed. Thank you to anyone that has read, commented and otherwise inspired me to keep writing along the way. Participating in this community has enabled me to meet some fantastic people who continually engage me with their writing. I could not be more appreciative.

And of course, thanks to my wonderful wife who so kindly edits every damn one of these things. They would be far less coherent without her efforts. Thanks everyone!

Now that's enough of my blabbing, go play the game I made!

Labels:

Monday, April 26, 2010

The Horizon Looms Large


No post this week, unfortunately. DeathSpank is in the final stages before certification, which is tremendously exciting, but also a mountain of frantic work. For those that haven't finaled a game, it involves fixing wholly unexpected bugs like:

Description:
If game is paused as controller is unplugged and submerged in a bucket of chum, game will hang and possibly shock player.

Steps to Reproduce:
1. The user starts a new game.
2. Submerge controller in bucket of shark chum. Water will not work.
3. Pause game and unplug controller simultaneously.
4. Notice that upon cleaning and reconnecting controller, game will not respond.
5. User may be severely shocked if hands are improperly submerged in chum.

Please see attached screenshot.

Suggested Fix or Results:
Game should not hang and/or player should not be horribly electrified.

(I say this having nothing but love and respect for our awesome QA guys. However, they find the most amazing things that I can hold no one but myself responsible for.)

I'm really looking forward to having other people finally play (and hopefully enjoy) DeathSpank. Being able to see the finish line is great, so I hope you'll forgive the mild downtime during the final sprint.

Labels: ,