Thursday, February 21, 2013

Matching up players in action games.

I am currently reading up on cartography. I need to visualize the earth in such a way that distances are accurately depicted. The way to do this is to map the globe using Interrupted Sinusoidal Mapping. Why am I so interested in distances at the moment? It is because of multiplayer gaming.

One of my goals for 2013 is to release a multiplayer game. And writing multi player action games is hard. Especially if you consider that my games always have a strong theme in physics simulation. Distributing a physics simulation is so hard, I consider it unsolved and probably intractable as well. Games typically use hacks, tricks and fakery to give the illusion of a shared experience in a virtual world with simulated physics.

What makes multi player game development hard is not bandwidth restriction, but the network latencies. In action based games (not turn based) you want immediate responses to player input. This player input needs to be communicated over the network to other parties. Even at speeds that are near the speed of light, this communication takes a very long time from the computer's point of view.

The speed of light in vacuum is roughly 300,000km/sec. This seems really fast, but if a UDP packet needs to take a one-way trip to a player 15,000km away, it would take 0.05 seconds. And guess what, in 0.05 seconds our game will have rendered three frames at 60fps. Now this is under ideal circumstances. What if the information needs to make a round trip? Then it is already 6 frames. It gets worse with the latencies introduced by the network equipment. And what if the packet makes a detour to another hub, or worse a satellite hop? And worse of all, a UDP packet can get lost altogether.

As a game programmer, I have no control over the network equipment at a player's home and at his provider. I do have control on how I match up my players though. I cannot afford to have an online match where one player is in Europe and another is in Australia. The limited speed of the signal and the long distance will create large delays between when information is sent and when it is received. I need to do the match-making in my game lobby based on geography. And while doing that, I might just as well communicate this local nature of opponent selection to the players. So I am going to visualize the pool of potential opponents for the player using a mapped globe that accurately depicts distances.

To divide the globe into player pools, I was considering using time zones. This would give 24 partitions. But in a single timezone, there is a long north-south distance. So I will split those at the equator. As there are no gamers on the North and South Pole, the resulting 48 zones should be relatively compact.

The multi player gaming API in Apple's iOS is part of GameKit. It is hard to determine how Apple servers work when matching up players. I hope they take locality into account when matching players. But I have not been able to determine whether they actually do this. So I think I have to do the region encoding myself. There is a hook in iOS for this in the GKMatchRequest class. This class lets you divide players with the playerGroup property. And using the queryPlayerGroupActivity:withCompletionHandler: method of GKMatchMaker I could even visualize player activity on the globe map.

Keep an eye out on my blog, to follow my progress in this venture. And wish me luck, I need it. There is very little documentation on distributed simulations. The main resource on this subject is seven years old and available at Gaffer on Games. I will leave you with a sneak peek at my new game.

Tuesday, February 19, 2013

Computer History

I thought I would document my computer history here. It all started with a Sinclair ZX Spectrum 48K (1982), which much later got replaced by a Sinclair Spectrum Plus (the latter I did not use very much.)

The next computer was a PC-XT clone, with Intel 8088 microprocessor running at 8MHz, equipped with a rare HEGA (Hercules/EGA combo) graphics card.

While studying computer science at the University of Amsterdam, I bought the first computer with my own (not my father's) money, which was a SOYO 386DX at 33MHz. I later equipped this machine with a 387 coprocessor.

The next computer was again a PC, and again self-built from components. The processor was an Intel Pentium at 66MHz, and I remember FedEX stopping by to swap my processor with FDIV bug for a new one.

Next up, again a PC, and it was a really good deal at the bargain bin of a dealer at the HCC dagen. I bought a real multiprocessor motherboard equipped with two Pentium PRO at 200MHz. I was working at ElectroGIG at the time, and I chose it on the floating point performance which is paramount in ray tracing technology.

After ElectroGIG, I purchased a powerhouse. Pretty much the fastest processor money could buy, thanks to some funding from the Silicon Polder Fund. I bought it during a road trip to the US, from Aspen Systems in Colorado. It was a Dec Alpha based, 533MHz ev56 164LX system called Durango II.

While I was working at SARA super computer centre as a Virtual Reality specialist, one of the supers got dismantled. It was a Parsytec CC with 56 PowerPC processors. Each node was a PReP Blackhawk 603 board. Because it was capable of running Linux, the scrapped nodes were distributed to personel, and I received one. This computer was my home server for a long time.

SARA also encouraged and subsidized private computers for employees. Under the PC-Prive regeling I bought a mini laptop years ahead of its time. The Sony Vaio C1VE is more a piece of jewelry than a plain laptop, and it featured a novel CPU from Transmeta. I was following Transmeta actively at the time, as it employed my idol Linus Torvalds at the time.

After exotic architectures like DecAlpha and PowerPC, I bought another x86 PC. Shopping around I decided to get the very average-performance but attractively priced AMD Duron.

As I had my computer switched on day and night, performance was becoming less important to me, and I wanted something silent. My first attempt at HTPC was based on Via C3.

This got replaced with my second attempt at HTPC based on Mobile Pentium technology and an AOpen 915Gmm motherboard.

Tinkering with a Sony PS3 running linux got me interested in CELL SPU programming. This in turn landed me a job with SlantSix games in Vancouver. While in Vancouver I started exploring iOS and for this purchased a Mac Mini and a Macbook Air.