Tuesday, April 27, 2010

MMO Magic

Just some random musings here. Aeven's stats:
  • Strength: 119
  • Agility: 50
  • Stamina: 89
  • Intellect: 57
  • Spirit: 61
  • Damage: 107 - 145
  • Melee Speed: 2.20
  • Melee Power: 389
  • Melee Hit Rating: 5
  • Melee Crit Chance: 7.52%
  • Melee Expertise: 0
  • Armor: 4448
  • Defense: 244
  • Dodge: 11.24%
  • Parry: 9.96%
  • Block: 4.96%
  • Resilience: 0
  • Spell Bonus Damage:0
  • Spell Bonus Healing: 0
  • Spell Hit Rating: 5
  • Spell Crit Chance: 5.72%
  • Spell Haste Rating: 0
  • Mana Regen: 17
  • Ranged Damage: N/A
  • Ranged Speed: N/A
  • Ranged Power: 64
  • Ranged Hit Rating: 5
  • Ranged Crit Chance: 5.16%
All in all, 28 stats - 30, if you take melee and ranged damage as a minimum and a maximum value. Throw in 19 slots for items, and assume every item can have some sort of enhancement - that's essentially 38 pieces of information there. Add in another 12 items (six glyphs each for two different specs allowed by dual talent specialization), and that's 50 pieces of information.

If you figure that each value is stored as a 16-bit value - two bytes - that's 50 * 2 = 100 bytes.

What about talents? There's a theoretical maximum of 99 talents for each class - theoretical, because as far as I know, no class has a completely packed talent tree. Let's further say that each talent can be represented, on average, by three ranks; some are actually 5 rank talents, some are 1 rank talents. I have no idea how Blizzard might handle this sort of thing, but I expect that they'd do so bit-packing to keep sizes reasonable. So let's estimate that all classes can have their talents be represented in 256 bits or less - 32 bytes. Allow for dual-talent specialization, and that's 64 bytes.

Class abilities, profession skills, racials... all pretty simple to represent as a string of bits. Let's be generous an imagine that characters can have up to 256 abilities for their class, and a similar number for each profession (two primary, three secondary). Figure on two bytes per ability, and that's 32 bytes * 5 = 160 bytes.

What about reputation? Same thing. Two bytes per reputation, and, say, 64 possible factions. That's another 128 bytes.

Stats (100 bytes) + talents (64 bytes) + abilities (160 bytes) + reputation (128 bytes) = 452 bytes.

What's left? Bag space. Bank space. Cash, emblems, honor, and other currency that gets tracked separately. Heck, let's allow for 768 bytes for bags and bank... that's enough to record almost 400 items and any possible enhancements. Throw in another 128 bytes for recording information about currency. Oh, and 32 bytes for a name.

452 bytes + 768 bytes + 128 bytes + 32 bytes = 1380 bytes. I'm probably being sloppy there - I'm sure there's a way to pack this information more effeciently - but I've also omitted things like mounts, non-combat pets, hunter pets, and the like. So let's almost double that size, and make it a nice even 2048 bytes to give us plenty of room for all that extra information.

This article, so far, clocks in at 2941 bytes.

Remember 3 1/2" floppy disks? They could hold 1.44 MB. That's enough space for 720 WoW characters, at 2K per pop.

Now, I'm guessing that Blizzard doesn't store characters as a string of bytes on disk, one character per file. With backups, maintaining game state, statistics tracking, and everything else that goes into WoW, I'm sure that a single character takes up more than a measly 2K. Add in the overhead for the state of the world, and the storage cost per character can probably get pretty hefty.

Still.... you could probably do it in less than 2K. Experience with the game says that the server is able to ship us data about other players pretty quickly, which implies pretty compactly. Just consider how quickly you get information on someone when you inspect them, for example.

2K. Less data than your average page in a novel. Less data than 99.9% of the pages you'll ever encounter on the world wide web. Barely enough to answer a final exam essay question decently.

Yet it's enough to bring a character to life, and give you hours of enjoyment as you wander through a virtual world.

Now, that's magical.

1 comment:

  1. I figure that since Spirit is an integer, they must have instantiated an integer object for it on the server, which would of course inherit all sorts of useful methods from some universal base class, but take up a few K of memory. Multiply by sixty or so for attributes, and...

    ...wait, you say they didn't implement it in Java? Oh, well never mind then. I imagine your estimates are correct.