Thursday, June 26, 2008

What's this Blog About?

I just switched from my company's official blog to my own blog. That's kind of exciting, but it means that absolutely know one knows about this blog. (Almost no one knew about our company blog. It was mostly employees.)

That's great! It lets me talk to myself for a bit while I try to organize the blog a bit. :)

I want to answer a simple question first. What the heck is this blog about?

Well, it's about things that interest me. However, I'm the only one who's going to visit a blog about that. (Maybe my wife? Cindy? Are you there?) Okay, so what interests me? Perhaps if people got a clear idea of what I talked about, then they'd know if they wanted to come here.

I like talking about problems that I've had. In the case of this particular post, it's about a problem that I've got right now. Many times, however, I've solved the problem already.

No one's going to read a blog with that little direction, though.

I can say that I'm a big fan of unusual solutions to problems. This is true in my life, but, if I find an unusual solution that works for me, I'm likely to write about it. You probably see a lot more unusual solutions on this blog than I typically come up with in my life. However, not all of my posts have involved unusual solutions to problems. That's okay. There's more than a few posts.

The title of my blog uses the word Programming. I do a lot of that. Programming is a great place to find unusual solutions to a wide variety of problems, too. One of the great things about diverging from our official blog is that I can talk about anything I want to.

I'm guessing that it'll end up being a blog about unusual solutions to problems in programming and game design. That's way too verbose.

Fred on Programming is wonderfully vague. I'll stick with that.

Wednesday, June 18, 2008

Science in World of Warcraft

Eleven million people play Blizzard's World of Warcraft game. Blizzard is watching them, and they are recording what they do. Almost everything is recorded. Even obscure things like what is said in chat channels is stored.

In other words, Blizzard knows what you're doing and what you're saying. They keep these records for a long time, too, so let's assume that they can track what you've done over the entire lifetime of your World of Warcraft account.

I'm going to try really hard to ignore all privacy issues here. Feel free to be worried about this, but please be reasonable. This is a game. This isn't even a game marketed to businesses for meetings. Don't spill your corporate secrets in a chat with your coworkers. Anyway, if it is a problem, it's a problem for another blog to investigate.

Instead, I want to look at what sort of science Blizzard could look at by analyzing all this data that they've gathered. There is an enormous amount of information in there that might have some relevance to social science.

I should be fair, though. Blizzard isn't alone. Academics don't have a lot of real world data to play with. Netflix released some of their data, and they ended up getting a lot of free research done for them. Demand for real data is high.

Let's look at some example applications of Blizzard's data.


Blizzard has already expressed a desire to help out two epidemiologists at Rutgers. They looked at an unintended virtual disease that spread through the game a few years ago. They got excited about learning more about how diseases spread by studying this effect. Blizzard was at least talking to them.

In addition, Blizzard is now talking about some new diseases that will come out in their next expansion. They may still be collaborating with the scientists!

How might this work? Somehow, Blizzard has to create a disease that spreads through some interaction between characters in the game.

They have to create a penalty system for the disease that will allow the scientists to gather useful information about how real diseases spread due to these social interactions.

I don't know much about epidemiology. I vaguely understand that they could eliminate some variables by comparing the behavior of one study group with another. There would be a lot of things to eliminate if they want to understand people's behavior in the real world based on what happens in a virtual world, though.

I will never tell someone that an ambitious and worthwhile project is impossible just because I don't see how to do it, however. I love those projects! I wish them luck, and I'm eager to hear what happens.

Social Networks

Duncan Watts, over at Columbia University, does a lot of work on how social networks interconnect. I'll admit that I haven't talked to him about his research in about 10 years, but he's the only social scientist that I know.

He looks at all the social interactions between people in a group and how they connect together. He's done some work on how viral marketing works, for example. Go ahead and click on the previous link. Trust me, it's interesting.

Blizzard's data would be a huge help for him. Blizzard can make extremely accurate measurements of how much two players interact. They can measure almost every interaction between every pair of players in the game.

Given Blizzard's data, Duncan could look at a viral marketing campaign in minute detail. He could analyze every interaction and see why it was successful or not successful.

Furthermore, Blizzard's game is divided into hundreds of almost completely separated servers. Players on one server don't interact much with players on other servers. He could run experiments on multiple servers and get essentially independent results.

The best part is that these interactions are similar to real world interactions. They're in a game, but that's the largest difference. The epidemiologists have a much greater difference to figure out.

Quantifying Fun

I'd be shocked if Blizzard isn't working on this one. Their goal is to make fun games. The only question is how much they're willing to rely on quantitative analysis.

They've got an immense database of how people interact with their world. They should be able to measure the fun that people are having and see what affects it.

The first step would be to make up a metric. If I were them, I'd try to estimate the amount of effort a player is putting into the game at each minute. They might not store all of that information, but they should be able to make some good guesses.

For example, if a player is casting spells as fast as their avatar is able to, then they are likely pushing themselves at least a bit. If a player is motionless for several minutes in between actions, then they are probably not paying close attention.

I'd try to argue that the first person is having more fun than the second person. I'm sure Blizzard can come up with a better metric.

Now look at each activity in the game. Is a player, on average, more active or less active during those activities?

There are literally thousands of activities that could be measured. A variety of correlations could be found.

Would any interesting science come out of this?

I honestly have no idea. I'm certainly not a psychologist, but I have to suspect that, again, the enormous amount of high quality data is going to be better in many ways than a conventional study.

I'd bet that some interesting revelations would be found.

Does This Happen?

Blizzard isn't going to answer that question. They can't afford the public relations mess that would result.

Blizzard's employment website has a few "data analyst" positions, but I don't see anything more specific than the mention of the existence of a data warehouse.

All of the examples that I came up with should be valuable to Blizzard.

The epidemiology study would be some science that they could work on without scaring their customers much. Publicizing research like that would be an enormous public relations feat.

Learning about social networks in their game might allow them to try to influence relationships formed in the game. I'd be willing to bet that a slight increase in the number of friendships created in the game would dramatically increase customer retention.

Making an accurate measurement of the amount of fun people have doing various things in the game would directly impact Blizzard's ability to model the value of new features they're working on. They could tweak old features more accurately as well.

I suspect that Blizzard works on some of this. At the time of this writing, there are four data analysis positions on Blizzard's job site. That's more jobs than Blizzard's new mobile development team has.

Surely a large group like that is analyzing something more interesting than their customers' zip codes?

Friday, June 13, 2008

Why I'm Creating an Independent Blog

I'm separating my personal blog from PC-Doctor's blog. This isn't an uncommon thing to do, but I suspect that some people will wonder if something went wrong. Nothing did. Instead, I expect this to benefit everyone. Read on to find out how.

I'll continue to contribute to PC-Doctor's blog, but I will actively market only the new blog. Since neither I nor anyone else currently does any marketing for our official blog, this may actually help out the official blog. Furthermore, I'll be able to talk about more than just programming here.

Why make such a sudden shift? Chris Keller, our online marketing guy, convinced me that a blog should be more than just a fun place to write down your thoughts. In part, he used Avinash Kaushik's great post here to convince me. He also showed me his own blog. However, I've been thinking about doing the same thing for other reasons.

This raises several interesting questions. First, why didn't I post links to my blog posts around the internet to try to get people to notice PC-Doctor's blog? You can rephrase the question slightly and ask why its better for me to market a blog that's separate from PC-Doctor.

The fundamental problem is that the official blog is not my blog. It has and it has to have a different purpose than a personal blog. I might occasionally write about things like video game design on the official blog, but I always made it relevant to our software. Running trails around Reno and what I might do if a bunch of 12 year olds start shooting guns at the trail in front me really doesn't fit at all on a corporate blog. It might fit here just fine.

In addition, because it's a blog about my stories, I might not mind advertising it on forums or other blogs. The reward for doing that marketing is that this blog has, over the course of several years, the chance of getting a following. Except for Andy, the PC-Doctor blog does not have much of a following. An increased number of people posting in my comments would be a large reward for me. This will require me to market my blog, and it's not entirely clear that I'll have the energy to do much of that, but I certainly didn't want to do it when it wasn't owned by me.

Should PC-Doctor change something about their blog to make it easier for people like me to stay there? No, they shouldn't. PC-Doctor's blog right now is mostly a bunch of posts by me. Customers coming to my posts will see that PC-Doctor hires at least one person who think on their own, and potential employees who come to my posts will see a confusing assortment of topics that may interest some of them. However, no one will buy our products because of my posts.

In fact, if you dig a bit deeper, there are some valuable posts there by other people. Kim Seymour wrote a great article that customers probably would be interested in. (Actually, I liked it, too. You should click on it if you have any interest at all in what PC-Doctor does.) Aki has written some fantastic articles, mostly about non-PC hardware. They've got interesting stuff to say that's relevant to our customers, and my post hides what they're saying.

Hopefully, we'll do something to encourage other employees to write more. Currently, employees are supposed to write on their own time with almost no reward. Some incentive, either monetary or otherwise, might help out. When we first started out, PC-Doctor gave away a Wii for the most prolific poster. Chris Hill won it, and I was jealous. :) They've got another prize up for grabs now as well, but it hasn't been as effective.

Writing a blog has turned out to be fun for me. I'm already convinced. It's been a great way to organize my thoughts about a topic, and I've learned quite a bit while doing it. I expect to continue to have fun in its new location.

I should point out that Doug van Aman, our marketing lead, has been nice enough to get me the copyright for the existing posts that I made. (Thanks, Doug!) I copied them all over verbatim. Without my existing library of posts, it would be much harder to do this.

Tuesday, June 3, 2008

Enums in C++ Suck

Like most strongly typed languages, C++ has a way to group a set of constants together as their own type called enums. Enums are extremely useful in a wide variety of circumstances. However, enums in C++ have a lot of problems, and, in fact, they're really a mess. I'm certainly not the only person to complain about this, either.

Enums don't fit in with the rest of the language. They feel like something that was tacked onto the language to me. This is purely an aesthetic issue, and the fact that they're useful in a wide variety of circumstances probably negates this.

More practically, you can't control the conversion of the enum to and from integers. For example, you can use the less than operator to compare an enum and an integer without using a cast. This can result in accidental conversions that don't make sense.

Perhaps the worst problem is the scope of the constants defined by the enum. They are enclosed in the same scope as the enum itself. I've seen a lot of code where people prepend an abbreviation of the enum's type to each of the enum's constants to avoid this problem. Adding the type to the name of a constant is always a good sign that something bad is happening.

In addition, you can't decide ahead of time what the size of your enum's type is. C++ normally tries to give the programmer as much control as possible. In the case of enums, this allows the compiler to store your enum in whatever type it wants to. Frequently, this doesn't matter, but when it does matter, you'll end up copying the value into an integer type that's less expressive than than the enum.

After the break, I'll explain what other languages are doing about it, what the next iteration of the C++ standard will do about it, and what you can do about it now.
I'll use a simple example for this dicussion:

enum Shape {
Circle, Triangle, Square
bool shouldBeAnError = Circle < 0;

C# has enums that behave a lot closer to what I'd like. This is what they look like:

enum Shape {
Circle, Triangle, Square
// Note the wonderfully ugly conversion and the need to explicitly
// say that circles are shapes.
bool isALotMoreExplicit = Shape.Circle < (Shape)0;

I'm not the first person to notice this problem, obviously. The next iteration of C++, C++0x, is going to add a much safer enum. This is what it'll look like:

enum class Shape
: int
Circle, Triangle, Square
// Note that we have to explicitly say that Circle is a Shape. That's great.
// The current standards document doesn't say how I can convert an int
// to the enum, though. I'll see if I can post a comment on that...
bool isALotMoreExplicit = Shape::Circle < (Shape)0;

It's actually not so hard to do a lot of that yourself if you throw out idea of using enums. For example, at home, I use something that looks a bit like this:

DECLARE_ENUM( Shape, int, (Circle)(Triangle)(Square) );
bool isAsExplicitAsIWant = Shape::Circle < Shape(0);

With only a bit of preprocessor magic, you can do the same thing.

Here at PC-Doctor, we define our enums in an XML file and use a code generation step to create the enum. The end result is the same as the preprocessor method: the enum can do whatever you want it to do.

While standard C++ enums are relics of C, lack most of the safety that C++ programmers are used to, and have a variety of other problems, there are ways around the problem. C++0x will add another alternative, but it lacks the flexibility of a home grown solution. You may decide to stick with your own solution even after your compiler starts supporting the new enums.

This post was originally published on the PC-Doctor blog.