What is a board?

A board B is a subset of P × P × R × T, where P is the set of positions, R is the set of directions and T is a subgroup of the symmetric group of R. Its elements are called links. They satisfy two conditions:

  1. For each pair (a,k) in P × R there is at most one pair (b,r) in P × T with (a,b,k,r) in B.
  2. For each link (a,b,k,r) in B there an inverse link (b,a,r(k),s) in B, where s denotes the inverse of r.

The data structure of a board used by BoardGame is declared in the following DTD:

<!ELEMENT board (field+, dir+, perm+)>
<!ATTLIST board
	name CDATA #REQUIRED
	image CDATA #REQUIRED>

<!ELEMENT field (link*)>
<!ATTLIST field
	id ID #REQUIRED
	l CDATA #REQUIRED
	t CDATA #REQUIRED
	w CDATA #REQUIRED
	h CDATA #REQUIRED>

<!ELEMENT dir EMPTY>
<!ATTLIST dir
	id ID #REQUIRED>

<!ELEMENT perm (map*)>
<!ATTLIST perm
	id ID #REQUIRED>

<!ELEMENT map EMPTY>
<!ATTLIST map
	s IDREF #REQUIRED
	t IDREF #REQUIRED>

<!ELEMENT link EMPTY>
<!ATTLIST link
	t IDREF #REQUIRED
	d IDREF #REQUIRED
	p IDREF #REQUIRED>

This means that every board consists of a list of fields, directions and permutations. It has two attributes: A name and a background image, which is included as a reference. A direction is an atomic object with a unique name. Permutations are sets of map object, each of them defining the image (target, t) of a direction (source, s) under the action of the permutation. Finally, each field contains information about its position (left, top, width, height) and a list of links, which consist of a target field t "neighboring" the source field, a direction and a permutation which acts on all directions when the link is passed.

Imagine this board:

It looks simple, doesn't it? Let's call the directions r and l, where r means to go to the right and l means to go to the left. Let's further call the six fields a,b,c,d,e,f. This board can be written as:

<?xml version="1.0"?>
<board name="sample board" image="sample.gif">

<dir id="r"/> <!-- go to the right !-->
<dir id="l"/> <!-- go to the left !-->

<perm id="p1">
	<map s="r" t="l"/> <!-- back from right means left !-->
	<map s="l" t="r"/> <!-- back from left means right !-->
</perm>

<field id="a" l="16" t="16" w="32" h="32">
	<link t="b" d="r" p="p1"/>
</field>

<field id="b" l="48" t="16" w="32" h="32">
	<link t="c" d="r" p="p1"/>
	<link t="a" d="l" p="p1"/>
</field>

<field id="c" l="80" t="16" w="32" h="32">
	<link t="d" d="r" p="p1"/>
	<link t="a" d="l" p="p1"/>
</field>

<field id="d" l="112" t="16" w="32" h="32">
	<link t="e" d="r" p="p1"/>
	<link t="a" d="l" p="p1"/>
</field>

<field id="e" l="144" t="16" w="32" h="32">
	<link t="f" d="r" p="p1"/>
	<link t="a" d="l" p="p1"/>
</field>

<field id="f" l="176" t="16" w="32" h="32">
	<link t="e" d="l" p="p1"/>
</field>
</board>

Now transform this via XSLT using this stylesheet. If your browser supports XSLT, you can view the XML file directly. Otherwise, choose the translated version.