03.01.2013 Views

Chapter 1

Chapter 1

Chapter 1

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

For protocols such as Bluetooth, which are fast and free, this is too heavyweight. It produces<br />

the oddity that, when playing Battleships over Bluetooth, you don't see a response to your<br />

move until the other player has decided what move to take. That's OK over SMS, but over<br />

Bluetooth it feels odd.<br />

It would be possible to add either another layer, or a fairly compatible modification, to RGCP:<br />

� This could allow responses to be sent immediately, without waiting for a piggyback<br />

packet.<br />

� Given the possibility of an immediate response, requires an immediate response in<br />

some situations and, if one does not arrive, resend automatically.<br />

I have provisionally called this protocol QRGCP (Q = quick), but haven't implemented it.<br />

CRgcpSession could use better construction encapsulation. Rather than providing a C++<br />

constructor to be followed by either ConstructL()or RestoreL(), it would be better to<br />

provide two public NewL()s, one with construct semantics and the other with restore<br />

semantics.<br />

The Battleships Protocol<br />

BSP, the Battleships Protocol, builds on RGCP to allow players to play the two-player game.<br />

Within the span of a single conversation (or 'session'), multiple Battleships games may be<br />

played. Outside a session, you cannot play a game.<br />

A session is set up by one partner initiating and the other listening. Partners specify whether<br />

they want to move first, or move second, or don't care. The decision is arbitrated in favor of<br />

the initiating partner (who will go first if they so requested, or if neither party cares, or if the<br />

other partner asked to go second).<br />

Normal play consists of a sequence of move requests. The game may be finished by being<br />

won by one partner (and therefore lost by the other) or by being abandoned by the player<br />

whose turn it is to move. If the game is finished in either of these ways, the session remains<br />

active and another game can be started. This time, the player who lost or abandoned gets<br />

preference for the first move.<br />

The RGCP session may be terminated, at any time, which of course terminates any game<br />

currently in progress.<br />

Protocol Overview<br />

Here's a brief look at the details of BSP.<br />

States<br />

The possible states of a Battleships application are<br />

State Meaning<br />

Blank No conversation is established. The game is in an arbitrary state (either a<br />

neutral state if the program has just started, or the state at the end of the<br />

last game if a conversation has been terminated).<br />

Initiating You have chosen whom to play against and initiated a conversation with<br />

them. You have also specified your first-move preferences. The game is<br />

initialized to a neutral position.

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

Saved successfully!

Ooh no, something went wrong!