03.01.2013 Views

Chapter 1

Chapter 1

Chapter 1

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

� define getter and setter functions for this struct, which change its members,<br />

� define getter and setter functions for a protocol level, which get a struct from the level's<br />

current settings, or set the settings from the values in a struct.<br />

Clearly, a different struct would be required for each level in the protocol stack.<br />

The capabilities pattern is particularly worthwhile for a protocol layer with many capabilities,<br />

especially if that layer often resides towards the bottom of a stack.<br />

16.6.2 Other Games<br />

TOGS isn't designed for Battleships alone. Any turn-based game could be implemented on a<br />

TOGS stack, using GDP, GSDP, and RGCP unchanged, but replacing BSP and the<br />

Battleships game.<br />

Suitable games would include Chess, Checkers (Draughts), Backgammon, Tic-Tac-Toe<br />

(Noughts and Crosses), Connect Four, Scrabble, and many other games, including twoplayer<br />

card games.<br />

The developer investment required to produce a good game on top of TOGS is not high,<br />

since you don't have to build in the intelligence required for a human-versus-computer<br />

version of these games. You only have to specify and implement the protocols required to<br />

communicate moves, the rules needed to referee attempted moves, and a GUI.<br />

Other games will probably use a variant of BSP. However, the details will be subtly different.<br />

Board games are based on a single shared game state (the board and pieces on it) that is<br />

public to both players. Battleships is a game of two halves, in which each player's initial fleet<br />

disposition is initially unshared, but as the game progresses it is selectively revealed to the<br />

other player.<br />

Many games include some combination of shared state and unshared state. In Scrabble, for<br />

instance, the knowledge of your letters is private to you, the unused letter pool is unknown to<br />

anyone, and the board state is completely public. Many card games rely on guessing<br />

unshared state for much of the interest in the game. The whole intrigue in multiplayer<br />

Diplomacy (though not the two-player version) arises from selective, and not always truthful,<br />

sharing of state between players.<br />

The degree of shared state will have some effects on your game protocol. A key rule in<br />

gaming is to minimize disclosure – that is, don't share things at the protocol level and hide<br />

them at the UI level. For instance, in Battleships, it would be possible to exchange the entire<br />

state of each player's board at the beginning of the game, so that the response to hit<br />

requests could be instant. But then a knowledgeable player could find out the state of the<br />

opponent's game, and win in 20 moves.<br />

16.6.3 Single-player Games<br />

Solo Ships was an attractive and useful single-player version of Battleships – possible<br />

because Battleships is really two half-games.<br />

Another single-player form of Battleships would involve the computer as a genuine<br />

opponent. The basic game design would use two CGameEngines, and two CFleetViews<br />

(one for my fleet and one for the opponent fleet). Instead of having an app view, the other<br />

engine would have a CGameComputerPlayer, which would make hit requests on behalf of<br />

the computer.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!