[messages] [Developers] Design of property and piece XML for V4

Julien Cassignol ainulindale at gmail.com
Mon Sep 10 05:12:16 MST 2012


Uckelman asked me to clarify. Here's the (hopefully effective)
clarification. Beware, it's long.

First, please consider that I'm more inclined towards types because I think
that this enforces a way to design which I deem more desirable. It forces
the designer to structure its objects in terms of a hierarchical tree in
which objects have shared properties.
A good example is the units, we'll have something such as :

             UNIT
      /                 \
INFANTRY      VEHICLE
                        /      \
                   TANK  BIKE

Translated: a bike is a vehicle, but also an unit. An infantry isn't a
vehicle but is a unit. A tank is a vehicle but is not a bike.
Your typical object model.
The fact that one is strictly forced to model its thoughts using that kind
of thought process is of value, to me, in terms of what we allow and what
we will have to debug.

In terms of functionnality, Uckelman's concepts as well as mine are, I
think, the same with more or less verbosity depending on the situation. I
just think that his is too much permissive or doesn't give enough
information to the engine.
That's why I think that having a type hierarchy in the XML, with "abstract"
objects extended by implementing objects, is easier.

In the following examples, I assume that parameters are transferrable
through hierarchy of template or type uses, as well as the usability of
"id" as a parameter.

Here's an example. Consider 4 decks of cards, each with one color from 1 to
K:

Both solutions will share this:

<image id="1-hearts" img="image/1-hearts.png" />
<image id="2-hearts" img="image/2-hearts.png" />
...
<image id="K-spades" img="image/K-spbackK-spades.png" />
<image id="back" img="image/tubgirl.png" />

----------------------------------
My proposal:
----------------------------------

<piece id="card" abstract="true">
  <parameter id="COLOR">
  <body>
    <stringProperty id="color" value="{COLOR}" />
    <face id="front" img="{id}-{COLOR}" />
    <face id="back" img="back" />
  </body>
</piece>

<deck id="carddeck" abstract="true">
  <parameter id="COLOR"/>
  <body>
    <piece id="1" extends="card">
    <piece id="2" extends="card">
    <piece id="3" extends="card">
    ...
    <piece id="Q" extends="card">
    <piece id="K" extends="card">
  </body>
</deck>

<deck id="hearts" extends="carddeck">
  <parameter id="COLOR" value="hearts" />
</deck>

<deck id="spades" extends="carddeck">
  <parameter id="COLOR" value="spades" />
</deck>

<deck id="clubs" extends="carddeck">
  <parameter id="COLOR" value="spades" />
</deck>

<deck id="diamonds" extends="carddeck">
  <parameter id="COLOR" value="spades" />
</deck>

----------------------------------
Uckelman's proposal:
----------------------------------

<template id="card">
  <parameter id="COLOR">
  <body>
    <stringProperty id="color" value="{COLOR}" />
    <face id="front" img="{id}-{COLOR}" />
    <face id="back" img="back" />
  </body>
</template>

<template id="carddeck">
  <parameter id="COLOR"/>
  <body>
    <piece id="1" extends="card">
    <piece id="2" extends="card">
    <piece id="3" extends="card">
    ...
    <piece id="Q" extends="card">
    <piece id="K" extends="card">
  </body>
</template>

<deck id="hearts" extends="carddeck">
  <use template="deck">
    <parameter id="COLOR" value="hearts" />
  </use>
</deck>

<deck id="spades" extends="carddeck">
  <use template="deck">
    <parameter id="COLOR" value="hearts" />
  </use>
</deck>

<deck id="clubs" extends="carddeck">
  <use template="deck">
    <parameter id="COLOR" value="hearts" />
  </use>
</deck>

<deck id="diamonds" extends="carddeck">
  <use template="deck">
    <parameter id="COLOR" value="hearts" />
  </use>
</deck>



Another example illustrating what I wrote before for units:

----------------------------------
My proposal:
----------------------------------
<piece id="unit" abstract="true">
  <parameter id="HITS">
  <body>
    <intProperty id="hits" value="{HITS}">
  </body>
</piece>

<piece id="vehicle" abstract="true" extends="unit">
  <parameter id="ONBOARD_PERSONEL">
  <body>
    <intProperty id="onboardPersonel" value="{ONBOARD_PERSONEL}">
  </body>
</piece>

<piece id="tank" abstract="true" extends="vehicle">
  <parameter id="GUNS_NUMBER">
  <body>
    <intProperty id="onboardPersonel" value="{GUNS_NUMBER}">
  </body>
</piece>

<piece id="bike" abstract="true" extends="vehicle">
  <parameter id="SPEED">
  <body>
    <intProperty id="speed" value="{SPEED}">
  </body>
</piece>


<piece id="panzer" extends="tank">
  <parameter id="GUNS_NUMBER" value="1"/>
  <parameter id="ONBOARD_PERSONEL" value="3"/>
  <parameter id="HITS" value="4"/>
</piece>

<piece id="namelessBike" extends="bike">
  <parameter id="ONBOARD_PERSONEL" value="1"/>
  <parameter id="HITS" value="3"/>
  <parameter id="SPEED" value="150"/>
</piece>

<piece id="soviet" extends="unit">
  <parameter id="HITS" value="1"/>
</piece>

----------------------------------
Uckelman's proposal:
----------------------------------

<template id="unit">
  <parameter id="HITS">
  <body>
    <intProperty id="hits" value="{HITS}">
  </body>
<template>

<template id="vehicle">
  <parameter id="ONBOARD_PERSONEL">
  <body>
    <use template="unit" />
    <intProperty id="onboardPersonel" value="{ONBOARD_PERSONEL}">
  </body>
</template>

<template id="tank">
  <parameter id="GUNS_NUMBER">
  <body>
    <use template="vehicle" />
    <intProperty id="onboardPersonel" value="{GUNS_NUMBER}">
  </body>
</template>

<template id="bike">
  <parameter id="SPEED">
  <body>
    <use template="vehicle" />
    <intProperty id="speed" value="{SPEED}">
  </body>
</template>

<piece id="panzer">
  <use template="tank">
    <parameter id="GUNS_NUMBER" value="1"/>
    <parameter id="ONBOARD_PERSONEL" value="3"/>
    <parameter id="HITS" value="4"/>
  </use>
</piece>

<piece id="namelessBike">
  <use template="bike">
    <parameter id="ONBOARD_PERSONEL" value="1"/>
    <parameter id="HITS" value="3"/>
    <parameter id="SPEED" value="150"/>
  </use>
</piece>

<piece id="soviet">
  <use template="bike">
    <parameter id="HITS" value="1"/>
  </use>
</piece>

Now if we suppose that in scripts or even in XML, we'd like to implement
behaviors such as "impassable for vehicles" (lets say, a river), here comes
the difference: uckelman's proposal will need to define a property to
define the type of the object. Mine won't as it's implicit in the
modelization.

Even though the functionnality is the same, I like to be able to say "a
river isn't crossable by vehicles", and see the same in the grammar, say,
hypothetical implementation:

<token id="river">
  <disallowedPieces>
    <piece type="vehicle" />
  </disallowedPieces>
</token>

I hope this gave you food for thoughts.

-- 
Julien Cassignol
http://www.ainulindale.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vassalengine.org/pipermail/messages/attachments/20120910/1c086c04/attachment-0001.html>


More information about the messages mailing list