Indie Game Development - "Having fun, making fun"

Tuesday, July 24, 2012

Dev Log - Bandwidth and Latency

I really enjoyed implementing the compression techniques for multiplayer, and have had great success with it.  I was able to reduce the server's bandwidth from 50,000 bytes to a peak of 7000 bytes.  Microsoft requires games going through their certification process to be below 8000.  While indie games do not have to meet this standard, I wanted to ensure my players had a good experience.

I was able to accomplish this using a variety of techniques that Shawn described in his blog.  First, I removed any data that was not really necessary at that moment.  For example, player stats are only needed after a match so I didn't need to update them during game play.  I also discovered that I didn't need to send a matrix for each character.  A matrix is a what the computer uses to store a 3D objects position, facing and scale.  Since my characters never change scale I didn't need the scale portion.  Since my characters never leave the ground, I was able to replace the 3D position and facing data with a smaller 2D vector data.  To top it off, I was able to further reduce the size using a compression technique called packed vertors.

The part that made me feel clever was when I was able to replace five interger values with a single half interger.  I realized that most of the numerical values I needed to send only had a range of 0-9.  Therefore, I saved a value in the one's place, another in the ten's place, another in the hundred's place and so on.

The last thing I did was offload some of the server's work to one or more clients.  In deathmatch for example, one of the clients is selected to manage any computer players, while the sever manages the balls.  In a sense therefore, there are kind of two servers.

All these techniques enabled me to meet my bandwidth goals while still sending data every frame - so I haven't had to trade bandwidth for latency.  My next step is to solve the latency problem.  After banging my head against a wall for a couple days, I've finally got a prediction system working for basic movement.  When I get back from vacation, I'll complete that work and let you know how it went.

Monday, July 16, 2012

Dev Log - Multiplayer Part II

I've discovered that I've been somewhat na├»ve concerning multiplayer.  I have multiplayer games working again over system link but when I added a full eight players and balls, the system got bogged down and fell out of sync.  After looking into the issue some more I discovered an excellent resource by Shawn Hargreaves that both explained my problem as well as offered strategies to address it. 

Shawn is part of Microsoft's XNA development team, and has taken the time to explain many technical issues on his blog.  His writings were extremely helpful when I tried to wrap my mind around 3D and he came to the rescue again in helping me understand online multiplayer.

Apparently multiplayer games are relatively "easy" to get working on a local network, but often fail when trying to get them to work in the real world over the internet.  This is because bandwidth is much more limited over the internet, packets of information take much longer to arrive, and some simply never arrive.  In my case, it seems I had forced the server to send so much information that I was having bandwidth problems even on my local network.  Ouch!

The good news it that I now understand what I need to do, its an interesting problem to solve and I'm excited to finally conqour multiplayer.  Using the compression techniques Shawn described I've already been able to reduce the client's bandwidth by 50%!  Sending the packets less frequently reduce it another 50%.  I'm now going to apply those techniques to the server, as well as offload some of the work to the clients.  Ever onward!

Wednesday, July 4, 2012

Dev Log - Multiplayer & Localization

Happy 4th of July to my American readers!  For Americans, the 4th of July marks our independence day, and is a time to celebrate our freedom.  Its always been a symbolic day for me, as it also marks the day 15 years ago when I left a good but ultimately unsatisfying 9-5 job to pursue my dream of making games.  Its been quite an adventure with rewards and sacrifices that went far beyond what the 9-5 job would have provided or required. 

It also marks the day I submitted my first indie game and therefore marks a different kind of independence.  I would have loved to submit my latest game on the 4th.  The single player is solid and fun.  The tutorial is complete.  All high prioirity bugs are fixed.  However two very important things remain: Multiplayer and Localization.

As I continued work on the single player game, new features were added that the multiplayer now needs to sync.  I've had great success getting the multiplayer back online but there's still much to do.  So I'm currently working through multiplayer bugs, and will be doing online focus tests.

The game is ready to be localized into as many languages as the Xbox supports and I can get translations for.  I am currenlty awaiting translations for Spanish and German.  I would still like to find someone who would be willing to translate the game into French, Italian or Japaneese.  So if any readers know one of these languages and would be interested in translating an indie game, let me know!

Well, it is the 4th today, so I will leave Multiplayer and Localization for tomorrow.  Today I will bake an apple pie and gather with family and friends to celebrate freedom.  Freedom of all kinds.