XEP-xxxx: Server-based Tic-tac-toe

Abstract:This document defines how to play a Tic-tac-toe game over XMPP
Authors:Arne König, Günther Nieß
Copyright:© 1999 - 2009 XMPP Standards Foundation. SEE LEGAL NOTICES.
Status:ProtoXEP
Type:Standards Track
Version:0.0.1
Last Updated:2009-03-14

WARNING: This document has not yet been accepted for consideration or approved in any official manner by the XMPP Standards Foundation, and this document must not be referred to as an XMPP Extension Protocol (XEP). If this document is accepted as a XEP by the XMPP Council, it will be published at <http://www.xmpp.org/extensions/> and announced on the <standards@xmpp.org> mailing list.


Table of Contents


1. Introduction
2. Requirements
3. Discovering Support
4. Game Roles
5. Match Configuration
6. Match State
7. Turns
8. Security Considerations
9. IANA Considerations
10. XMPP Registrar Considerations
11. XML Schema

Appendices
    A: Document Information
    B: Author Information
    C: Legal Notices
    D: Relation to XMPP
    E: Discussion Venue
    F: Requirements Conformance
    G: Notes
    H: Revision History


1. Introduction

It is quite common to play games over IM networks. Since Tic-tac-toe is a well-known and simple game, it's a good example for a server-based game protocol.

2. Requirements

This document addresses the requirements for a game protocol as defined by Multi-User Gaming [1]. In particular this consists of:

  1. game roles
  2. match state
  3. turns
  4. match configuration
  5. conditions for interrupting and terminating a match

The extensions needed to implement these requirements are qualified by the 'http://jabber.org/protocol/mug/tictactoe' namespace.

3. Discovering Support

An entity implementing this protocol MUST also support Multi-User Gaming [2] and answer to disco requests accordingly including both the Multi-User Gaming and the game <feature/> elements in the response.

Example 1. Service Informs Juliet That It is Capable of Hosting Tic-tac-toe

<iq type='result'
    from='games.shakespeare.lit'
    id='disco1'
    to='juliet@capulet.com/garden'>
  <query xmlns='http://jabber.org/protocol/disco#info'>
    ...
    <feature var='http://jabber.org/protocol/mug'/>
    <feature var='http://jabber.org/protocol/mug/tictactoe'/>
    ...
  </query>
</iq>
  

4. Game Roles

A Tic-tac-toe game uses two game roles, "x" and "o". Both roles have to be assigned to exactly one player to start a match. If one role gets unassigned or a player gets unavailable the match has to be paused.

5. Match Configuration

A service SHOULD offer a configuration form with the following options:

  1. starting role ("mug/tictactoe#config_first")
  2. size of the board ("mug/tictactoe#config_rows" and "mug/tictactoe#config_cols")
  3. the number of marks in a row needed to win ("mug/tictactoe#config_first")

An implementation MUST be able to handle the a board with three cols and rows and three respective marks to win. Everything beyond that is OPTIONAL.

Example 2. Service Sends Configuration Form

<iq from='tictactoe@games.shakespeare.lit'
    id='config1'
    to='juliet@capulet.com/garden'
    type='result'>
  <query xmlns='http://jabber.org/protocol/mug#owner'>
    <options>
      <x xmlns='jabber:x:data' type='form'> 
        <title>Tic-tac-toe Room</title>
	...
      </x>
      <options xmlns='http://jabber.org/protocol/mug/tictactoe'>
        <x xmlns='jabber:x:data' type='form'> 
          <title>Configuration for Tic-tac-toe</title>
          <instructions>
            Below you can see the default configuration. 
            To accept the default configuration, click OK. 
            To select a different configuration, please complete this form.
          </instructions>
          <field var='FORM_TYPE' type='hidden'>
            <value>http://jabber.org/protocol/mug/tictactoe#tictactoeconfig</value>
          </field>
          <field label='Number of rows' var='mug/tictactoe#config_rows' type='list-single'>
            <value>3</value>
            <option label='3'><value>3</value></option>
            <option label='4'><value>4</value></option>
            <option label='5'><value>5</value></option>
            <option label='6'><value>6</value></option>
            <option label='7'><value>7</value></option>
            <option label='8'><value>8</value></option>
            <option label='9'><value>9</value></option>
            <option label='10'><value>10</value></option>
          </field>
          <field label='Number of cols' var='mug/tictactoe#config_cols' type='list-single'>
            <value>3</value>
            <option label='3'><value>3</value></option>
            <option label='4'><value>4</value></option>
            <option label='5'><value>5</value></option>
            <option label='6'><value>6</value></option>
            <option label='7'><value>7</value></option>
            <option label='8'><value>8</value></option>
            <option label='9'><value>9</value></option>
            <option label='10'><value>10</value></option>
          </field>
          <field label='Strike' var='mug/tictactoe#config_strike' type='list-single'>
            <value>3</value>
            <option label='3'><value>3</value></option>
            <option label='4'><value>4</value></option>
            <option label='5'><value>5</value></option>
            <option label='6'><value>6</value></option>
            <option label='7'><value>7</value></option>
            <option label='8'><value>8</value></option>
            <option label='9'><value>9</value></option>
            <option label='10'><value>10</value></option>
          </field>
          <field label='Select a role who start the game' var='mug/tictactoe#config_first' type='list-single'>
            <value>x</value>
            <option label='x'><value>x</value></option>
            <option label='o'><value>o</value></option>
          </field>
        </x>
      </options>
    </options>
  </query>
</iq>
  

Submitting a strike option value bigger than the number of rows or columns SHOULD result in <not-acceptable/> error.

6. Match State

The state in a Tic-tac-toe match represents the match configuration, the player who makes the next turn and the current state of the board. Every state is distributed to all occupants.

Example 3. Service Sends Start State

<presence
    from='tictactoe@games.shakespeare.lit'
    to='juliet@capulet.com/garden'>
  <game xmlns='http://jabber.org/protocol/mug'>
    <status>inactive</status>
    <state xmlns='http://jabber.org/protocol/mug/tictactoe'>
      <rows>3</rows>
      <cols>3</cols>
      <strike>3</strike>
      <next>x</next>
      <board/>
    </state>
  </game>
</presence>
  

After a valid turn, the state gets updated with the corresponding mark.

Example 4. Service Sends Mid-Game State

<presence
    from='tictactoe@games.shakespeare.lit'
    to='juliet@capulet.com/garden'>
  <game xmlns='http://jabber.org/protocol/mug'>
  <status>active</status>
  <state xmlns='http://jabber.org/protocol/mug/tictactoe'>
      <rows>3</rows>
      <cols>3</cols>
      <strike>3</strike>
      <next>o</next>
      <board>
        <field row='1' col='1'>x</field>
        <field row='2' col='1'>o</field>
        <field row='2' col='2'>x</field>
        <field row='1' col='3'>o</field>
        <field row='2' col='3'>x</field>
      </board>
    </state>
  </game>
  

The match is considered terminated when the board is full or when one player reaches the number of respective marks as defined by the strike option. After termination the service broadcasts the final state including either a <draw> or <won> (including a game role) element to indicate the resulting score and the initial state of the next round.

Example 5. Service Sends Draw State

<presence
    from='tictactoe@games.shakespeare.lit'
    to='juliet@capulet.com/garden'>
  <game xmlns='http://jabber.org/protocol/mug'>
    <status>inactive</status>
    <state xmlns='http://jabber.org/protocol/mug/tictactoe'>
      <rows>3</rows>
      <cols>3</cols>
      <strike>3</strike>
      <next>o</next>
      <board/>
      <won>x</won>
    </state>
  </game>
</presence>
  

7. Turns

During the game, players change in turn, each of them MUST send only one move at a time. It MUST possess these attributes:

Table 1: <move/> attributes

Name Type Description
'id' REQUIRED The number of the move. First move is 1.
'row' REQUIRED The horizontal position of the mark.
'col' REQUIRED The vertical position of the mark.

Example 6. Juliet Sends a Move

<message 
    to='tictactoe@games.shakespeare.lit'
    from='juliet@capulet.com/garden'
    type='chat'>
  <turn xmlns='http://jabber.org/protocol/mug#user'>
    <move 
        xmlns='http://jabber.org/protocol/mug/tictactoe' 
        row='3' 
        col='2' 
        id='7'/>
  </turn>
</message>
  

8. Security Considerations

The author is not aware of any security issues introduced by this protocol extension.

9. IANA Considerations

This document requires no interaction with the Internet Assigned Numbers Authority (IANA) [3].

10. XMPP Registrar Considerations

The XMPP Registrar [4] shall include 'http://jabber.org/protocol/mug/tictactoe' in its registry of protocols.

11. XML Schema


Appendices


Appendix A: Document Information

Series: XEP
Number: xxxx
Publisher: XMPP Standards Foundation
Status: ProtoXEP
Type: Standards Track
Version: 0.0.1
Last Updated: 2009-03-14
Approving Body: XMPP Council
Dependencies: XMPP Core, XEP-xxxx
Supersedes: None
Superseded By: None
Short Name: Not yet assigned


Appendix B: Author Information

Arne König

Email: arne.ko(ät)23inch.de
JabberID: arne++(ät)jabber.ccc.de

Günther Nieß

Email: guenther.niess(ät)web.de
JabberID: niess(ät)jabber.ccc.de


Appendix C: Legal Notices

Copyright

This XMPP Extension Protocol is copyright © 1999 - 2009 by the XMPP Standards Foundation (XSF).

Permissions

Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.

Disclaimer of Warranty

## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. In no event shall the XMPP Standards Foundation or the authors of this Specification be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification. ##

Limitation of Liability

In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising out of the use or inability to use the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.

IPR Conformance

This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which may be found at <http://xmpp.org/extensions/ipr-policy.shtml> or obtained by writing to XSF, P.O. Box 1641, Denver, CO 80201 USA).

Appendix D: Relation to XMPP

The Extensible Messaging and Presence Protocol (XMPP) is defined in the XMPP Core (RFC 3920) and XMPP IM (RFC 3921) specifications contributed by the XMPP Standards Foundation to the Internet Standards Process, which is managed by the Internet Engineering Task Force in accordance with RFC 2026. Any protocol defined in this document has been developed outside the Internet Standards Process and is to be understood as an extension to XMPP rather than as an evolution, development, or modification of XMPP itself.


Appendix E: Discussion Venue

The primary venue for discussion of XMPP Extension Protocols is the <standards@xmpp.org> discussion list.

Discussion on other xmpp.org discussion lists might also be appropriate; see <http://xmpp.org/about/discuss.shtml> for a complete list.

Errata may be sent to <editor@xmpp.org>.


Appendix F: Requirements Conformance

The following requirements keywords as used in this document are to be interpreted as described in RFC 2119: "MUST", "SHALL", "REQUIRED"; "MUST NOT", "SHALL NOT"; "SHOULD", "RECOMMENDED"; "SHOULD NOT", "NOT RECOMMENDED"; "MAY", "OPTIONAL".


Appendix G: Notes

1. XEP-xxxx: Multi-User Gaming <http://pidgin-games.sourceforge.net/xep/multi-user_gaming.html>.

2. XEP-xxxx: Multi-User Gaming <http://pidgin-games.sourceforge.net/xep/multi-user_gaming.html>.

3. The Internet Assigned Numbers Authority (IANA) is the central coordinator for the assignment of unique parameter values for Internet protocols, such as port numbers and URI schemes. For further information, see <http://www.iana.org/>.

4. The XMPP Registrar maintains a list of reserved protocol namespaces as well as registries of parameters used in the context of XMPP extension protocols approved by the XMPP Standards Foundation. For further information, see <http://xmpp.org/registrar/>.


Appendix H: Revision History

Version 0.0.1 (2009-03-14)

First Draft.

(ak)

END