Last Modified: $Date: 2002/02/01 14:28:09 $ by $Author: ferret $

# Content of XML files

> In this file you will find the XML specification for each type of object that is able to be represented in XML.
> The organisation is always the same:
> - an example of the object in XML
> - explanation of attributes or tags
> - errors handling, means what's the result if this attribute is not a number for example
> - the name of the class that parses this kind of object

## Food Map

> A food map is defined as below:

> > [1] <?xml version="1.0" encoding="UTF-8"?>
> > [2] <FOODMAP size="4">
> > [3] <FOOD type="B" value="0.60541725" color="black"/>
> > [4] <FOOD type="s" value="0.24649799" color="red"/>
> > [5] <FOOD type="A" value="0.054020107" color="0,0,0"/>
> > [6] <FOOD type="n" value="0.1527639" color="black"/>
> > [7] </FOODMAP>

> A food map has only one attribute (size ligne [2]) that represents the number of foods it contains.

> ### Food

> > All foods contained in the food map body will be part of the food map.
> > A food has three attributes:
> > - a type, that represents its name. This name must be unique.
> > - a value, that represents the amount of energy won (or lost) by a worm when it eats it. This value can be negative.
> > - a color, that represents the color of the food. This argument is used only when there is a visual representation of the food. The color can be represented by a string like "red", or simply by a RGB representation like "10,15,67".

> Errors management:
> - if the size attribute is not an integer, then parsing is stopped.
> - if the size attribute is absent, then parsing is stopped.
> - if the size attribute is not representative of the amount of foods, then memory will be lost but parsing will not stop.
> - if the value attribute is not a float, then parsing is stopped.
> - if the value attribute is absent, then default value will be randomly generated for this food
> - if the name attribute is absent or empty, then parsing is stopped
> - if the name attribute is already defined, then first defined food will be erased by the new one
> - if the name attribute is not a character, then first character will be used
> - if the name attribute is "I" (a reserved letter) then parsing will stop
> - if the color attribute absent, then a pur color will be randomly generated.
> - if the color attribute is not a valid color (name or RGB), then default color will be white.
> XML Handler:
> - Food map parsing is handled by the class fr.lifl.aquarium.model.xml.FoodMapHandler.

## Life Room

> A life room is defined as below:

> > [1] <?xml version="1.0" encoding="UTF-8"?>
> > [2] <LIFEROOM type="fr.lifl.aquarium.model.CharMatrix" width="5" height="50">
> > [3] <ROOM linear="0" value="a"/>
> > [4] <ROOM linear="1" value="1"/>
> > [5] <ROOM linear="20" value="a"/>
> > [6] </LIFEROOM>

> A life room has three attributes:
> - type that represents the type of life room.
> - width the width of life room.
> - height the height of life room.

> ### Room

> > All rooms contained in the life room body will be part of the life room.
> > All rooms absent will be presumed as empty rooms.
> > A room has two attributes:
> > - a linear, that represents the linear coordinate of this room. A linear coordinate is a coordinate that follow the rule: linear=y*width+x. It is always comprised in [0, width*height[.
> > - a value, that represents the contents of the room. Value "1" is reserved for wall and "2" is reserved to worms body. Other letters will be considered as food types.

> Errors management:
> - Warning!, if after saving a life room that contains Worms, you decide to edit and change the XML file, you can do it but do not forget that these are linear coordinates, so changing just the size may break some worms body, and this will generate errors and inconsistency.
> - if the type attribute is not a class available in the classpath, then parsing is stopped.
> - if the type attribute is absent, then parsing is stopped.
> - if the width or height attributes is not a positive or null integer, then parsing is stopped.
> - if the width or height attributes is absent, then parsing is stopped.
> - All abstent ROOM are considered as empty rooms.
> - if the linear attribute is not comprise in [0, width*height[ or is not an integer, then parsing is stopped.
> - if the linear attribute is absent, then parsing can stop but if it does not then the resulted life room can be inconsistent.
> - if the value attribute is absent, then default value will be empty
> - if the value attribute is invalid, first char will be used for filling the map, if string is empty, then empty value will be used
> - if the value attribute is not a food type, its not important
> XML Handler:
> - Food map parsing is handled by the class fr.lifl.aquarium.model.xml.LifeRoomHandler.

## A Worm

> A worm is defined as below:

> > [01] <?xml version="1.0" encoding="UTF-8"?>
> > [02] <WORM age="427" name="5729904" direction="R" life="-1374.75">
> > [03] <DNA foodsType="CBA" color="73,240,170" isPerfect="false" length="6">
> > [04] <HALO type="fr.lifl.aquarium.model.halo.ProportionalHalo" size="3"/>
> > [05] <GENE key="IAC" value="FRL"/>
> > [06] <GENE key="IAB" value="FLR"/>
> > [07] <GENE key="BBC" value="LFR"/>
> > [08] <...>
> > [09] <GENE key="BBB" value="RLF"/>
> > [10] <GENE key="BBA" value="FRL"/>
> > [11] <GENE key="IAI" value="FLR"/>
> > [12] </DNA>
> > [13] <BODY>
> > [14] <COORDINATE x="117" y="62"/>
> > [15] <COORDINATE x=116" y="62"/>
> > [16] <COORDINATE x="116" y="61"/>
> > [17] <COORDINATE x="117" y="61"/>
> > [18] <COORDINATE x="118" y="61"/>
> > [19] <COORDINATE x="119" y="61"/>
> > [20] </BODY>
> > [21] </WORM>

> A Worm has four attributes:
> - age that represents the number of turn since he is alive.
> - name its name.
> - direction where it is looking at R for Right, L for Left, F for Front and D for Down.
> - life the amount of energie it has.
> Errors management for Worm's attributes:
> - if the age attribute is not a valid positive integer, then parsing is stopped.
> - if the age attribute empty or absent then default age will be zero.
> - if the name attribute is empty or absent then hashkey of the object will be used.
> - if the direction attribute is not a valid char like R, L, F or D then parsing is stopped.
> - if the direction attribute is empty or absent then F will be the default direction.
> - if the life attribute is not a float, then parsing is stopped. Life can be positive or negative value
> - if the life attribute is empty or absent then zero will be the default life value
> A Worm is composed by
> - DNA that represents its Dna
> - BODY that represents its body

> ### DNA

> > A DNA has four attributes:
> > - foodsType that represents types of food known by the worm.
> > - color the color of the worm.
> > - isPerfect is a boolean value that indicates if this worm is perfect or not.
> > - length the size of the worm.
> > Errors management for DNA's attributes:
> > - if the foodsType attribute is empty or absent parsing will stop.
> > - if the color attribute empty or absent then a random color will be used.
> > - if the color attribute is not an RGB value (12,15,48) or a String value (red, blue ...) then color will be white.
> > - if the isPerfect attribute is empty, absent, or not a boolean value (true, false) then false will be the default value.
> > - if the length attribute is empty, absent, not a valid positive integer then parsing will stop.
> > - If the number of COORDINATE tag available in the BODY tag is < or > to the DNA length attribute then parsing will stop.
> > A DNA is composed by
> > - HALO that represents the halo of the worm.
> > - GENE that represents a gene of the DNA.

> > ### Halo

> > > A HALO has two attributes:
> > > - type that represents its type. Means how is computed the look algorythm
> > > - size the maximum visibility range of the halo.
> > > Errors management for HALO's attributes:
> > > - if the type attribute is empty or absent parsing will stop.
> > > - if the type attribute is an unknown class then parsing will be stopped .
> > > - if the size attribute is empty, absent or not a valid positive integer then parsing will be stopped.
> > > - if the size attribute does not respect range defined in preferences then parsing will continue.

> > ### Gene

> > > A GENE has two attributes:
> > > - key that represents what sees the worm. This key is composed of 3 letters. First letter represents what's on the left of the worm, second letter is what can see the worm in front of him, and last letter is what's on its right.
> > > - value that expresses how will react the worm. Here, each letter is a move, R means move Right, L means move Left, F means move Front.
> > > So, if a key is "AII" and the value is "RFL", it means that if the worm's Halo says "I am able to see AII", then the worm will try to move first in the Right direction, if it can't it will try Front, and finaly it will try Left.
> > > The "I" letter is reserved, and means nothing (walls, empty square, worms, in fact all that is not identified as a food type).
> > > Errors management for GENE's attributes:
> > > - if the key attribute is empty or absent parsing will stop.
> > > - if the value attribute is empty or absent parsing will stop. A value should always be composed by 3 different letters, a value with "FFF" is meaningless and should not be used, but if it does, it won't stop the parsing

> ### Body

> > A BODY has no attribute, but is composed of COORDINATE tags.
> > A COORDINATE has two attributes that indicates where is located the body of the worm.
> > - x that represents the x coordinate of this body part.
> > - y that represents the y coordinate of this body part.
> > Errors management for BODY's attributes:
> > - if the x attribute is empty, absent or not a valid positive integer then parsing will stop.
> > - if the y attribute is empty, absent or not a valid positive integer then parsing will stop.
> > - If you load a worm in a new LifeRoom smaller than its first (means where it was born) LifeRoom, then its body will find a new place to be.
> > - If the number of COORDINATE is < or > to the DNA length attribute then parsing will stop.

> XML Handler:
> - Worm has no handler, but you can find information about parsing Worm in the fr.lifl.aquarium.model.xml.WormListHandler class.