Volity

Chapter 1. Volity at a Glance

Chapter 1. Volity at a Glance

Volity is a project that aims to provide the world with a vast network of multiplayer computer games. More specifically, it provides enough tools and existing network infrastructure to give developers a head start in implementing new games, which act as modules on a network-based system; this system then helps make these new games immediately available to all the world's game-players, giving them many interesting ways to find them, learn about them, and play them with friends, no matter what computer platform they happen to use.

This chapter begins with a look at some of the Volity system's unique features, and then continues with a more in-depth view of the various technologies and other components that make up the system. It concludes with a prose transcript of a typical Volity play session.

Note

While it can theoretically be applied to any sort of multiplayer computer game, the Volity system currently limits its intended scope to the sorts of games where network latency times prove less of an issue, and usually this means turn-based games, or other pursuits where precise timing is not critical. This allows Volity to use communication technologies without worry about the overhead that individual messages carry, and furthermore lets games run on platforms that introduce latency-times of their own, such as cellular phone networks.

When this book talks about games, it generally will refer to these less time-senstive games that the young Volity project is more comfortable supporting.

Why Volity is Cool

Networked computer games are certainly nothing new, and the concept of a general system for playing these games as modules certainly doesn't originate with Volity. That said, this project does advance a significant number of features and strategies that no other Internet-based game system can so far claim.

For programmers and game developers

Games are programmed for the Volity system as modules, rather than stand-alone applications. This allows for much faster development, not just because there's less code to write, but because so many of the components necessary to create a fully functional networked computer game already exist, provided by one's module programming framework of choice, as well as the Volity network itself.

  • User management is handled at the network level. Because Volity is based on Jabber, all Volity users are simply Jabber network users, with login information stored according to Jabber's rules on one server or another, with additional information specific to game-playing stored on centralized Volity servers.

  • Core network handling happens entirely through XMPP, the communication protocol on which the Jabber IM system is based. Any computing platform that can handle both TCP/IP and XML parsing — which is to say, any remotely modern system — can also handle Jabber's protocols, and Volity's as well.

  • Player-to-player and player-to-server communication are, once again, present in Volity thanks to Jabber's instant-message protocols. Game programmers create interactivity in their modules by writing handlers that react to incoming messages, either IM-style ones or special XML-RPC calls defined by the Volity protocol to make game-specific things happen.

  • Graphics will still have to be created for your games, but Volity alleviates some of the stress from this task by restricting all graphics to SVG documents, manipulated through ECMAScript (a.k.a. JavaScript). All your game's visual interface pieces exist as SVG objects, linked to your program logic through special ECMAScript functions, allowing player activity to trigger events within your game, and giving your code opportunity to update its players' visual fields (individually, or all at once) at any appropriate time.

    Furthermore, since graphics libraries exist as independent files, they can be re-used across games, and (with proper licensing) be shared among several game developers' projects.

See the section called “The technologies of Volity” for a brief but more detailed tour through the alphabet soup of technologies mentioned in this list.

For game players

Since Volity standardizes its graphics and communication protocol across all the games it supports, a single Volity network account and a good client application allows a player to play every single well-programmed game on that network, regardless of what computer platform that player is using (or what platforms any of those game servers run on, for that matter). Note that this also reflects back on Volity's attractiveness for game developers, since it makes their games' potential audience as wide as possible.

In some ways, this is not unlike what a player experiences through game systems accessed by a Java-enabled Web browser, such as Yahoo! Games. However, the idea of variety extends beyond the concept of games, since an open system architecture means that people can create client applications specific to different computing platforms, with user interfaces finely tuned to the various play and communication tasks involved in using a game network. This can prove a much more satisfying user experience than performing everything through a Web browser window.

Again showing how Volity's features for developers and users are intertwined, the system's open nature plays a subtle role in the variety of games available to players: since (unlike closed systems like Yahoo!'s) any developer can create a game module and add it to the Volity network, the landscape of Volity games is ever-growing and always changing, and can prove as fun to continually explore as the games themselves are to play!

The Volity Protocol

While we often refer to "the Volity protocol", in truth Volity isn't so much a communication protocol unto itself as it is a system with rules for using various other protocols which have already well-established by the Internet programming community (though none are older than XML, the technology upon which they all site). By clever application of the technologies listed in the section called “The technologies of Volity”, Volity creates the multi-compenent, indefinitely extensible network described in the section called “The Components of a Volity Network”.

Without question, Volity's most important "parent-protocol" is Jabber, the humble yet ambitious instant-message network that happily acts as Volity's substrate, perfoming a great deal of the system's grunt work: managing user accounts, defining the different ways users can query remote entities for service discovery, and generally handling all communication sent among human users and machine-based services.

When two Volity components need to communicate in a fashion too game-specific for Jabber to comfortably handle by itself, the system turns to XML-RPC, a standard way for programs running on two different machines to communicate. When a Volity client application, for example, wants to ask a Volity game server to start a new game, the call is sent out via XML-RPC (which, in turn, uses Jabber as its transport).

The next section presents a brief tour of these and other technologies that Volity has in its core. We'll then move on to describe how Volity brings them together into a single system for playing games.

The technologies of Volity

The Volity concept takes much of its strength from the fact that it's almost wholly built from various proven Internet technologies, of which we shall now take a brief tour. A full volity implementation must make use of all these technologies, each of which is common (and old) enough to have at least one good programming library available for any given popular computing platform.

Jabber

Jabber is an open instant-messaging (IM) standard. From the enduser's standpoint, a typical Jabber application works a lot like a client program used with one of the more popular (and proprietary) IM networks, such as AOL Instant Messenger or MSN Messenger. With both Jabber and these other systems, every user on the network (which usually operates as part of the world-wide Internet) has a globally unique idenitifier of some sort, and messages that users send one another, either person-to-person or in a group-chat of some kind, appear instantly to the receiver. In principle this isn't too different than ordinary email, but IM's central conceit is the notion of presence, where a description of the user's online status — such as "available", "idle", or "offline" — becomes available to any entity that asks, thus making continually updated user rosters (a.k.a "buddy lists") possible, letting users know which other users are around to receive their messages.

Jabber's uniqueness in the IM field (which is, admittedly, dominated by the aforementioned proprietary networks) comes from its completely open design. Unlike AOL or MSN, the Jabber Council[1] publishes the core protocol where all the world can see, allowing programmers to build applications or IM code libraries that make use of it. Furthermore, the Council uses a request-for-comments (RFC) system, inviting the public at large to suggest and decsribe possible extensions to the protocol, which may then enter a period of review and, after time and proven usefulness, possible standardization.

This open paradigm also allows programmers, even ones with no affiliation with the core Jabber development team, to use the protocol — and the network that supports it — in all kinds of interesting ways. Most examples of programmer creativity in the Jabber world take the form of chat-client applications, which allow the users of various computer platforms (or cross-platform platforms, such as Java) to make use of Jabber's IM features in various ways. However, enterprising programmers can extend the protocol, adding features and and functionality beyond basic instant-messaging. And this brings us to Volity.

Volity uses Jabber — and its underlying, XML-based protocol, XMPP[2] — as its one underlying communication transport. Jabber/XMPP (and the various standard Jabber extensions) cover enough ground to actually do most of the work for Volity. In truth, Volity's protocol is more a collection of guidelines on how to use someone else's protocol in order to get the job done, versus the collection of low-level message definitions one usually expects to see when reading about a communication protocol. (That said, Volity does possess those sorts of things too, in the form of XML-RPC calls — though these too get a free ride from Jabber, as the section called “XML-RPC” describes.)

Jabber Reference on the Web

Because Volity depends so heavily on the Jabber protocol, this book makes frequent references to its various core parts, as well as many of its standardized extensions. Readers interested in learning more about any of these protcol pieces can easily follow along via the Jabber Foundation's protocol-reference webiste, which contains the full text of all the standards to which we'll make reference. Wherever possible, we'll help you by noting the spot in that document collection you'll find whatever it is we're describing at the time.

SVG

SVG, which stands for Scalable Vector Graphics, is an XML-based standard for representing vector-based images. An SVG document describes all the points, lines, paths and shapes that make up an image; it's up to a separate viewing application to interpret this code into something visible. Examples of general-purpose SVG-viewing applications include Adobe's SVG Viewer plug-in for Web browsers, and the Apache XML Project's Squiggle stand-alone Java application.

Figure 1.1 shows an example of an SVG fragment, describing a playing card image.

Figure 1.1. An SVG playing card, in code and on-screen

<!-- "&#x2660;" is the XML character entity for the Unicode "spade" glyph. -->
<symbol style="fill: black" id="AS">
	<rect width="100" ry="10" rx="10" style="stroke: black; fill: white;" height="140" />
	<text y="110" style="font-size: 100; text-anchor: middle" x="50">&#x2660;</text>
	<text y="74" style="font-size: 10; text-anchor: middle; stroke: white;" x="50">jmac.org</text>
	<text y="15" style="font-size: 15" x="5">A</text>
	<text y="30" style="font-size: 15" x="5">&#x2660;</text>
	<text y="15" transform="rotate(180, 50, 70)" style="font-size:15" x="5">A</text>
	<text y="30" transform="rotate(180, 50, 70)" style="font-size:15" x="5">&#x2660;</text>
</symbol>	      
	    

While static SVG images are nice enough, giving users the ability to scale and transform them however they wish without loss of image quality, the real power of the language (as far as its game-playing potential is concerned) comes when it's partnered with the ECMAScript scripting langauge. This lets you use the DOM object model[3] to treat the image as a collection of separate, individually-identifiable symbols (or "actors") that can follow a script in order to animate themselves and react to user input. When hosted over a network, this can make for highly dynamic, server-side graphical user interfaces that rival (and, some would argue, surpasses) ones makes with proprietary technologies in the same sphere, such as Macromedia's Flash.

Games running within the Volity framework use SVG and ECMAScript for all their graphical user-interface needs. A typical Volity client application will, for every game in which the user is currently involves, maintain one SVG viewport winow which contains the game's user interface. (Interacting with other people playing the game is a different matter, involving the use of core Jabber messaging protocols, and clients will typically manage such messages in other, simultaneous windows.) Note that some games can get along fine without using SVG at all; word games, for example, can be played wholly through a text-only interface, using nothing more complex than ordinary Jabber messaging. However, any Volity client, server, or game-toolkit software package must implement SVG before it can be considered complete.

XML-RPC

The XML-RPC protocol defines a simple way for running programs to call functions defined elsewhere, often on completely different machines reachable over the Internet. (RPC stands for Remote Procedure Call.) In a nutshell, the protocol specifies how to send requests, which inlcude a function name and an argument list, to the receiver, as well as the responses that the caller should always receive back.

Volity uses XML-RPC as a catch-all technology to do everything too specific to the application of game-playing for handling by the general-purpose Jabber protocol. Fortunately, Jabber allows us to meet it halfway, providing its own standard for couching RPC requests and responses within Jabber messages[5].

XML

While the pattern is no doubt obvious by now, we'll nonetheless give a tip of the hat to XML in general. Volity gets away with calling itself a fully XML-based technology simply because all of its technological componenets — all the things mentioned in this section — are themselves XML applications.

Note

Because XML lay two levels deep in Volity's technology stack, this book will not go into much detail about XML, what it is, or how it works. Ideally, Volity programmers, using code libraries that abstract out all the nasty XML-handing work, won't need to deal with it much (and Volity end-users should certainly never see it at all), but you'll still see snippets of it lying around this book and its related reference materials. If you're not already familiar with XML, now's a good time to get started; despite its grand reputation, it's really not all that complicated a concept. We recommend pointing your Web browser at a xml.com and continuing on from there.

The Components of a Volity Network

When we speak of a Volity network, we mean a collection of Volity-compliant game servers organized around a central, record-keeping server — the bookkeeper. The term also includes players, which are really just Jabber users who happen to be accessing the network through a Volity client that knows both the general language of Jabber (for chatting with other people, keeping a privite contact list, and so on) and the more specific language of Volity (for finding, starting, and watching games, looking at other player's game-related records, and the like).

Each entity on the Volity network — bookkeper, game server, or player — possesses a unique Jabber ID, more commonly known as a JID. One of the fundamental Jabber concepts, a JID is analagous to an email address, both in function and appearance, being a short text string that uniquely identifies the entity, and acts as the handle by which the entity may be referred to by other critters lurking on the network. In everyday Jabber IM usage, people send messages addressed to one anothers' JIDs. Players in the Volity world do this as well, and can also send special messages to game servers by their JIDs, or query the network's bookkeeper by its own JID.

Note

This ubiquitous JID-assignment strategy means that, from the underlying Jabber network's point of view, every Volity entity is just a Jabber user. Note that, even though there's only one bookkeeper on the network, Volity doesn't do anything special when addressing messages to it. Throughout all its message-passing activity, Volity sticks to the rules laid down by the core Jabber protocol.

We shall now examine the anatomy of a simple but complete Volity network, as sketched in Figure 1.3.

Figure 1.3. A simple Volity network

The Bookkeeper

As its name suggests, the bookkeeper's role in the Volity network involves managing all the game and players records generated by game activity. Whenever a game ends, the bookkeeper hears about it, taking note of who played, who won, what server hosted it, and the like. Thereafter, players can query the bookkeeper (directly through their clients, or indirectly through a website, as the section called “The Website” covers) to learn about that game. The bookkeeper also holds similarly queriable directories of all the system's known game servers and players.

In the network depicted by Figure 1.3, the bookkeeper has the JID bookkeeper@example.com. This is the Jabber address to which the network's game servers will send their records of completed games, and from which clients will receive information about the network's active games, player rankings, and other information. The bookkeeper is able to respond to all these requests by maintaining a connection to the Jabber server hosted on example.com (where it has the username bookkeeper, hence its particular JID)

Game Servers

A Volity game server is an automated process that knows how to play a game of some sort, and allows players to create tables where this game can be played. The game played at each table is overseen by another process under the game server's jurisdiction, called a referee, who handles all server-to-player (and player-to-server) communication for that particular game instance.

From the network's point of view, game servers do not actually host the game; like every other Volity component, it's simply another user-level node of the Jabber system. Rather, it listens for, and responds to, RPC requests from players (and may also handle other sorts of Jabber messages, such as personal chats, depending upon how its programmed). The most important of these is the new_table request, sent by a player that wishes to start a new table. When it receives this request, a server makes sure that all conditions for a new table are met (that it has enough computing resources to do so, for example, and that the player making the request isn't on any black-hole lists the server cares about), and then proceeds to create the table — which is simply a normal Jabber MUC[6] (multi-user conference, or "chat room"). It then informs the player about the table's location (i.e. its JID, for every MUC on a Jabber network, even a temporary one, has its own unique Jabber ID), allowing the player's client to join. From there, the player may invite friends to join, or advertise the table's existence to the world, or even just summon up some computer-controlled bot players as instant opponents. (See the section called “An example Volity session” for an illustration of this activity in context.)

The distinction between game servers and their referees is subtle but important. Game servers listen for requests from the network at large, but don't really pay any attention to actual games being played, even at tables that it created. That's the job of the referee at each table, who pays full attention to that table alone, including the game currently in play there (if any). In fact, the referee is the game, to a great degree, since the current state of any table's game is known wholly by the referee, and it must describe the game individually to each player. Generally, it performs this by activating ECMAScript functions stored on the player's client, which in turn cause the client to modify something in its SVG-based visual display to the player.

The referee is also the target of communication from the client to the game, as when the player clicks on an image with an attached method. For instance, a game might have display a "Roll dice" button, or an animated image of the dice themselves, which, when clicked, send a roll_dice message to the table's referee. Typically, the referee would respond by determining the die roll, then sending to that player's client (or all players, if the roll isn't secret) an instruction to activate a ECMAScript function which displays the roll's result.

Referee as GM

Those familiar with tabletop roleplaying games, such as Dungeons & Dragons, might appreciate the metaphor comparing a Volity referee to a game master. It holds the whole game concept, and its current state, "in its head", and its the sole interface between the players and the game world, continually updating their current perspective on it. Players are free to talk to each other, but to make anything happen in the game world, they have to to talk to the referee, who lets them know what happens as a result.

Players

Any network entity capable of sitting at a Volity table and playing games is a player. Most players are humans, connecting to the network through specialized client applications. Like everything else on the Volity network, every player possesses a unique JID, the domain part of which reflects only the Jabber server they use to connect to the network, and says nothing about the game servers or bookkeper they use.

Note

Since ordinary Jabber servers can act as the hosts of Volity players, people who already have Jabber accounts can re-use their existing Jabber IDs for Volity, just by adding a resource string; so the JID alice@jmac.org can become alice@jmac.org/volity, for example.

A player can also be a bot, which is simply a computer program that acts like a player. Volity makes no formal distinction between its human and machine players; just as with human players, bots accumulate their own permanent, publically-visible records as they play games, and can earn (possibly negative) reputations over time (as described in the section called “The Reputation System”).

Client applications

Human players (as opposed to sinister, computer-controlled bots) connect to the Volity network through specialized client applications, much as they'd use a Web browser to access the Web, or an IM client to use an IM network. Volity can call itself a cross-platform technology because these clients can be written for any computing platform which can support the various networking technologies listed in the section called “The technologies of Volity”. This includes all the major OSes avaialble today, from Windows to Mac OS to Unix and Linux, as well as cross-platform environments like Java.

Out of necessity, a Volity client will, in both use and internal structure, rather resemble a Jabber IM client. It should support the user's keeping a roster of buddies and sending instant messages to them, as well as joining conference chats (which make the basis of game tables) and sending Jabber information-querying messages to game servers and the bookkeeper. It will also, however, have plenty of Volity-specific functions for starting new games, looking up game records, and so on. Most importantly, it must know how to interpret and visually render SVG graphics, and manipulate them through ECMAScript, since most games use these two technologies to build their user interfaces.

Volity clients are "thin", when it comes to the actual business of playing games. All the work of describing any particular game world is performed server-side, by that game's referee. Through fluency in both SVG and the Jabber protocol (with the thin layer of RPC that Volity adds on top), a well-programmed Volity client should be able to play with any compliant Volity game server, since the client isn't expected to make any decisions about game play itself; it helps the player find games to play, and, once found, merely displays the SVG graphics the referee chooses to send. Player interactivity with that game happens through methods tied to various graphical objects; these triggers are all defined through the SVG and ECMAScript files that the game sends the client during setup, so again, the client itself has little to do with that process.

Note

While a game is in progress, other client-side activities, such as chatting with other players (either at the same table or busy elsewhere on the network), can continue in the background, and a good client should be able to represent this appropriately through a multiple-window display or the like.

Other Concepts

Game modules

A volity game module is an implementation of some game's ruleset, compiled into a game server plugin. Part of Volity's strength comes from the fact that game modules are relatively easy to create, since Jabber handles network and user management, and the higher-level Volity protocol takes care of UI handling and display. A module programmer need only implement the game rules, and create a suitable UI through creative use[7] of SVG and ECMAScript documents.

The future may hold snazzy game construction kits, allowing people to put together Volity-ready games with even greater ease (though some programming skill will always be required). For now, though, Volity game programming is open to anyone able to learn there way around an existing toolset (such as the Perl modules and frameworks that the Frivolity reference implementation provides).

The Reputation System

Volity networks, ideally, are self-governing, operating with minimal top-level human moderation. Some of this emerges from the architechture itself, with its natural resilience to cheating (see the section called “Cheating”). Volity's reputation system attempts to address the touchier issue of inter-player conflict, giving players a simple and easy way to express their opinion about other players. Thus lets each player on the system build up, over time, a reputation score that reflects what their past opponents have thought of them, and thus encourage a sort of beneficial prejudice in potential opponents regarding whether or not this person would be fun to play with.

The system takes its cue from similar reputation-scoring systems seen on places like eBay or PayPal. When a game completes, all players involved have an opportunity to give one another a reputation point, either positive or negative (or neutral), with implications described by Table 1.1. This number is meant to represent whether or not the player in question was fun to play the game with, and the likelihood that the scoring player would want to play another game (of any variety) with the same person. It not not mean to represent their skill level at that game, but rather how they conducted themselves while playing it.

Table 1.1. Repuatation point-assignment meanings

Points givenMeaning for PlayersMeaning for Game Servers
-1I would not play any game with this person again. (Poor sport, rude, inconsiderate, tries to cheat...)I would not play on this server again. (Doesn't work, has terrible UI, doesn't follow game rules, appears to cheat...)
0I have no opinion about this player. (Plays by the rules, not especially friendly or helpful.)This server seems to be OK. (Works, has acceptable UI, nothing special.)
1I'd play with this person again. (Good sport, helpful, honest, friendly...)This server does its job very well, and I'd use it again. (Works great, fast, has excellent UI, helpful...)

As the table suggests, players can also assign reputation points to servers, as well as other players. If a player feels that a particular server plays is game exceptionally well, and offers a pleasant UI and speedy response to player input, then it deserves a point. Conversely, if a server doesn't seem to properly follow its own declared ruleset, or is miserable to use, or (worst of all) appears to cheat, then the disgruntled player is free to give it a negative point.

Reputation scores of both players and servers is public information. Players can use these scores to decide if a stranger is worth playing with, or if a game server is worth using.

The Website

The Volity Central website, beyond serving as a general information repository about the Volity system, also allows people to browse game and player records, create and manage player accounts, and bring new game servers to the bookkeper's attention. It uses fairly standard URLs for its various player services, so that "lazy" client applications can simply open a Web browser window in response to certain information requests from the user, such as looking up a player's profile.

These Volity Central services apply only to the main Volity network centered around the volity.net bookkeeper; other Volity networks must create, host, and run their own websites in order to receive similar functionality.

Cheating

One of Volity's slogans is "Games for everyone", and, alas, the set called "Everyone" does wholly include the subset called "Jerks". While the reputation system (see the section called “The Reputation System”) tries to discourage bad behavior during game-playing, Volity's design makes it actively difficult for uncouth players to cheat.

This is largely accomplished by how the system's different components trust one another — or, rather, how they don't. First of all, all trust is invested in the bookkeper, at the network's center, as described in A matter of (no) trust: Why is there only one bookkeeper?. From there, game servers are given leeway to speak for themselves, sending cryptographically-signed game records about games that they've overseen. These are stored on the bookkeeper, and assumed to be valid and factual, but if the orginating server receives a negative repuatation, then this can flavor — and, in extreme cases, even nullify — all the records it created in the past.

Finally, and most importantly, clients are trusted as little as possible. A sane, non-cheating game server will never send a client any information that wouldn't be available to that client's player. For example, in a Poker game, a proper server will tell each client which card-face graphics to use in order to represent that one player's hand, as well as any cards face-up on the table, with not the slightest clue about what might lay in the draw-pile, or in the other players' hands. (And non-player game observers can't "look over the shoulder" of any individual player, either.) If it's discovered that a server acts otherwise, through either bad programming or malicious intent (such as always sending full card-information to the player with the JID sneaky-pete@example.com), then its reputation should suffer accordingly.

Clients are furthermore kept thin, and "dumb". Since they can play all compliant Volity games, they don't "know" anything about any game in particular; they simply display the graphics and text messages that servers send to them. Therefore, no amount of clever client-side hacking can ever give players an unnatural advantage over their opponents; you'll never see a "card hack" that lets you peek at your opponents' hands. Real cheating must take place server-side, and once such a server's villainous ways are releaved to the world, then avoiding it is as easy as not playing games hosted by that server (and giving it, and perhaps its owner, a swift kick in the reputation system on your way out the door). Conversely, a "clean" server with a good reputation is guaranteed to give its players a cheat-free experience, no matter who plays on it, or what clients they use.

An example Volity session

To better illustrate how the Volity system works, let's follow along as a couple of people play a game — the venerable contest of Rock-Paper-Scissors[8], in this case.

The players in this drama:

  • A fully volity-compliant game server that faithfully implements the Rock, Paper, Scissors ruleset as defined by the http://volity.org/games/rps URI. The server's JID is rps@example.com, and it has registered itself with the bookkeeper, so the world of players-at-large can discover its existence.

  • One player, Alice, who holds the JID alice@jmac.org.

  • Another player, Bob, found at JID bob@example.com.

  • The official Volity network's bookkeper (bookkeeper@volity.net), making a special celebrity cameo for this example.

Let us further stipulate that Alice and Bob are friends who often settle disputes through a few rounds of RPS, but today they don't happen to be in the same location (perhaps they are to meet for lunch, but can't agree on where), so Alice proposes a game of RPS via Volity. Both sides fire up their client applications, and the store unfolds...

  1. Alice sees that the game server is available, and asks her client to start a new table there.

  2. The client begins by asking the game server (through an RPC request) for the URIs of the SVG and ECMAScript files that it uses for its UI. If it has files that support these URIs, all is well. Otherwise, it asks the server to send it fresh copies of these files, and proceeds immediately with the download. (via Jabber's file-transfer standards).

  3. The client then sends a new_table RPC request to the game server.

  4. On receiving the request, the server checks what resources it has available, and decides that it can afford to start a new table.

  5. The game server creates a new MUC on the MUC server it uses; in this case, the MUC's JID happens to be 123456@conference.example.com. This will serve as the table that Alice requested.

  6. The server creates a new referee, with JID, and has it log into the network under the JID rps@example.com/123456. The referee joins the new table. (In Jabber terms, it sends presence to the MUC.)

  7. The server sends Alice an RPC response, whose value is the MUC of the table it just created. Its task complete, the game server turns its attention back to listening for other RPC requests, and exits this tale.

  8. Alice's client application recieves the response and opens a new window representing the table, making various table-appropriate functions available.

    Note

    It sounds like a lot has happened so far, but from Alice's point of view, all she did was ask her client to start a new table at the server rps@example.com, and an instant later she sees a new table on her screen.

  9. Through controls offered by her client program, Alice sends Bob — whom she knows is online, thanks to her user roster — an invitation to join her at the table. Under the hood, her client actually asks the referee to make the invitation for her, and it does so.

  10. Bob gladly accepts the invitation, and his own client gives him a view of the same table, after making him undergo the same check for UI files that Alice went through when she created the table.

  11. Alice clicks a 'start game' button on her browser. This sends a start_game RPC request to the table's referee, which responds by performing a sanity check: in this case, making sure that exactly two players occupy the table.

  12. Seeing that this is the case, the referee begins the game! It sends a message to the clients of both Alice and Bob, calling the ECMAScript function on each that draws the initial game setup. This function simply draws three hand-shaped symbols — one for each possible RPS "move" — resulting in both players looking at a UI window resembling Figure 1.4. The SVG documents define the hand symbols as buttons, so that clicking them will send a message to the game's referee.

    Figure 1.4. A very simple game UI window (for Rock, Paper, Scissors)

  13. Stolid Alice chooses Rock, and makes her move by clicking on the fist icon. Crafty Bob picks Scissors, and clicks the appropriate hand in his own window. In both cases, the action triggers an ECMAScript function which in turn sends an RPC request to the referee, informing it of the player's action.

  14. The referee, having received a "gesture" from both players, judges Alice to be the winner, since Rock always beats Scissors. It informs the players of the outcome by triggering a victory-display ECMAScript function on Alice's browser, which places a congratulatory symbol in her UI window. Bob, alas, has his defeat-display function called, resulting in a more somber graphic (Figure 1.5).

    Figure 1.5. Updated game visuals, as seen by two different players

    Alice's view of the game.

    Bob's view of the game.

  15. As the game is now over, the referee creates a game record describing what just happened, and sends it off to the bookkeeper at volity.net, for permanent storage. The referee remains at the table, now waiting to see if Alice or Bob will ask to play again.

  16. Both players now have an opportunity to assign a reputation point to one another. (Since they're friends, it's likely that they've long since granted a positive point to one another.) Once that's done, they can play again ("Best of three?" asks Bob, via standard Jabber MUC communication), or they might just leave, at which point the referee will clean up the table and then itself.



[4] America On-Line, at the time of this writing.

[7] Or, often, re-use; as real-life games often have shared components, such as decks of cards, dice, or checkerboards, so shall Volity game modules be able to re-use SVG and ECMAScript documents and libraries that define common visual elements (such as... well, cards, dice, and checkboards, actually).

[8] Also known as janken or roshambo. You probably know how to play, but the author discovered that his mother had never heard of it, so if you find yourself in similar straits, see the World RPS Society's homepage.