Multiplayer Game Programming: An Overview of Networked Games
A Brief History of Multiplayer Games
The progenitor of the modern networked multiplayer game began on university mainframe systems in the 1970s. However, this type of game didn’t explode until Internet access became common in the mid-to-late 1990s. This section gives a brief overview of how networked games first started out, and the many ways these types of games have evolved in the nearly half century since the first such games.
Local Multiplayer Games
Some of the earliest video games featured local multiplayer, meaning they were designed for two or more players to play the game on a single computer. This included some very early games such as including Tennis for Two (1958) and Spacewar! (1962). For the most part, local multiplayer games can be programmed in the same manner as single-player games. The only differences typically are multiple viewpoints and/or supporting multiple input devices. Since programming local multiplayer games is so similar to single-player games, this book does not spend any time on them.
Early Networked Multiplayer Games
The first networked multiplayer games were run on small networks composed of mainframe computers. What distinguishes a networked multiplayer game from a local multiplayer game is that networked games have two or more computers connected to each other during an active game session. One such early mainframe network was the PLATO system, which was developed at the University of Illinois. It was on the PLATO system that one of the first networked games, the turn-based strategy game Empire (1973), was created. Around the same time as Empire, the first-person networked game Maze War was created, and there is not a clear consensus as to which of these two games was created first.
As personal computers started to gain some adoption in the latter part of the 1970s, developers figured out ways to have two computers communicate with each other over serial ports. A serial port allows for data to be transmitted one bit at a time, and its typical purpose was to communicate with external devices such as printers or modems. However, it was also possible to connect two computers to each other and have them communicate via this connection. This made it possible to create a game session that persisted over multiple personal computers, and led to some of the earliest networked PC games. The December 1980 issue of BYTE Magazine featured an article on how to program so-called Multimachine Games in BASIC (Wasserman and Stryker 1980).
One big drawback of using serial ports was that computers typically did not have more than two serial ports (unless an expansion card was used). This meant that in order to connect more than two computers via serial port, a daisy chain scheme where multiple computers are connected to each other in a ring had to be used. This could be considered a type of network topology, a topic that is covered in far more detail in Chapter 6, “Network Topologies and Sample Games.”
So in spite of the technology being available in the early 1980s, most games released during the decade did not really take advantage of local networking in this manner. It wasn’t until the 1990s that the idea of locally connecting several computers to play a game really gained traction, as discussed later in this chapter.
A multi-user dungeon or MUD is a (usually text-based) style of multiplayer game where several players are connected to the same virtual world at once. This type of game first gained popularity on mainframes at major universities, and the term originates from the game MUD (1978), which was created by Rob Trushaw at Essex University. In some ways, MUDs can be thought of as an early computer version of the role-playing game Dungeons and Dragons, though not all MUDs are necessarily role-playing games.
Once personal computers became more powerful, hardware manufacturers began to offer modems that allowed two computers to communicate with each other over standard phone lines. Although the transmission rates were extraordinarily slow by modern standards, this allowed for MUDs to be played outside the university setting. Some ran MUD games on a bulletin board system (BBS), which allowed for multiple users to connect via modem to a system that could run many things including games.
Local Area Network Games
A local area network or LAN is a term used to describe several computers connected to each other within a relatively small area. The mechanism used for the local connection can vary—for example, the serial port connections discussed earlier in this chapter would be one example of a local area network. However, local area networks really took off with the proliferation of Ethernet (a protocol which is discussed in more detail in Chapter 2, “The Internet”).
While by no means the first game to support LAN multiplayer, Doom (1993) was in many ways the progenitor of the modern networked game. The initial version of the id Software first-person shooter supported up to four players in a single game session, with the option to play cooperatively or in a competitive “deathmatch.” Since Doom was a fast-paced action game, it required implementation of several of the key concepts covered in this book. Of course, these techniques have evolved a great deal since 1993, but the influence of Doom is widely accepted. For much greater detail on the history and creation of Doom, read Masters of Doom (2003), listed in the references at the conclusion of this chapter.
Many games that support networked multiplayer over a LAN also supported networked multiplayer in other ways—whether by modem connection or an online network. For many years, the vast majority of networked games also supported gaming on a LAN. This led to the rise of LAN parties where people would meet at a location and connect their computers to play networked games. Although some networked multiplayer games are still released with LAN play, the trend in recent years seems to have developers forgoing LAN play for exclusively online multiplayer.
In an online game, players connect to each other over some large network with geographically distant computers. Today, online gaming is synonymous with Internet gaming, but the term “online” is a bit broader and can include some of the earlier networks such as CompuServe that, originally, did not connect to the Internet.
As the Internet started to explode in the late 1990s, online games took off alongside it. Some of the popular games in the earlier years included id Software’s Quake (1996) and Epic Game’s Unreal (1998).
Although it may seem like an online game could be implemented in much the same way as a LAN game, a major consideration is latency, or the amount of time it takes data to travel over the network. In fact, the initial version of Quake wasn’t really designed to work over an Internet connection, and it wasn’t until the QuakeWorld patch that the game was reliably playable over the Internet. Methods to compensate for latency are covered in much greater detail in Chapter 7, “Latency, Jitter, and Reliability” and Chapter 8, “Improved Latency Handling.”
Online games took off on consoles with the creation of services such as Xbox Live and PlayStation Network in the 2000s, services that were direct descendants of PC-based services such as GameSpy and DWANGO. These console services now regularly have several million active users during peak hours (though with expansion of video streaming and other services to consoles, not all of these active users may be playing a game). Chapter 12, “Gamer Services,” discusses how to integrate one such gamer service—Steam—into a PC game.
Massively Multiplayer Online Games
Even today, most online multiplayer games are limited to a small number of players per game session—somewhere from 4 to 32 is commonly the number of supported players. In a Massively Multiplayer Online Game (MMO), however, hundreds if not thousands of players can participate in a single game session. Most MMO games are role-playing games and thus called MMORPGs. However, there are certainly other styles of MMO games such as first-person shooters (MMOFPS).
In many ways, MMORPGs can be thought of as the graphical evolution of multi-user dungeons. Some of the earliest MMORPGs actually predated the widespread adoption of the Internet, and instead functioned over dial-in networks such as Quantum Link (later America Online) and CompuServe. One of the first such games was Habitat (1986) which implemented several pieces of novel technology (Morningstar and Farmer 1991). However, it wasn’t until the Internet became more widely adopted that the genre gained more traction. One of the first big hits was Ultima Online (1997).
Other MMORPGs such as EverQuest (1999) were also successful, but the genre took the world by storm with the release of World of Warcraft (2004). At one point, Blizzard’s MMORPG had over 12 million active subscribers worldwide, and the game became such a large part of popular culture that it was featured in a 2006 episode of the animated series South Park.
Architecting an MMO is a complex technical challenge, and some of these challenges are discussed in Chapter 9, “Scalability.” However, most of the techniques necessary to create an MMO are well beyond the scope of this book. That being said, the foundations of creating a smaller-scale networked game are important to understand before it’s possible to even consider creating an MMO.
Mobile Networked Games
As gaming has expanded to the mobile landscape, multiplayer games have followed right along. Many multiplayer games on these platforms are asynchronous—typically turn-based games that do not require real-time transmission of data. In this model, players are notified when it is their turn, and have a large amount of time to make their move. The asynchronous model has existed from the very beginning of networked multiplayer games. Some BBS only had one incoming phone line connection, which meant that only one user could be connected at any one time. Thus, a player would connect, take their turn, and disconnect. Then at some point in the future, another player would connect and be able to respond and take their own turn.
An example of a mobile game that uses asynchronous multiplayer is Words with Friends (2009). From a technical standpoint, an asynchronous networked game is simpler to implement than a real-time one. This is especially true on mobile platforms, because the platform APIs (application program interfaces) have built-in functionality for asynchronous communication. Originally, using an asynchronous model for mobile games was somewhat out of necessity because the reliability of mobile networks is comparatively poor to wired connections. However, with the proliferation of Wi-Fi–capable devices and improvements to mobile networks, more and more real-time networked games are appearing on these devices. An example of a mobile game that takes advantage of real-time network communication is Hearthstone: Heroes of Warcraft (2014).