Tech XML-Representation Attempt

Programmers discuss here anything related to FreeOrion programming. Primarily for the developers to discuss.

Moderator: Committer

Post Reply
Message
Author
LaplaceOperator
Space Squid
Posts: 60
Joined: Wed Sep 08, 2004 3:20 pm
Location: Switzerland

Tech XML-Representation Attempt

#1 Post by LaplaceOperator »

Hi

I'm just working on the tech loading code. And i was just wondering if it would be a favorable idea to put the description of the associated effect/effectgroup also into the tech-describing xml file as inline python...
The document structure looks like this so far.
1.) What do you think about the structure? (did i forget something?)
2.) inline python script?

Code: Select all

<FreeOrion::TechTree>
    <Category name="Social Science">
        <tech>
            <id>10</id>
            <name>Mark I</name>
            <description>Powerful solver for social problems (in- and outside the empire)</description>
            <rpperturn>10</rpperturn><!-- RP's needed to advance this project for one turn -->
            <research_duration>20</research_duration><!-- the minimum turns it takes to research it -->
            <vispretech>2, 4</vispretech><!-- list of techs needed to make this one visible in the ResearchScreen -->
            <unlpretech>2, 4, 9, 2</unlpretech><!-- list of techs needed to make this one researchable -->
            <effect>           <!-- inline python-script ??? would be cool -->
            <?pyscript
                dothis(withthis);
                dotthat(withthat);
                etc();
            ?>
            </effect>
            <subtechs> <!-- applied technologies -->
                <tech>
                    ...
                </tech>
                <tech>
                    ....
                </tech>
            </subtechs>
        </tech>
        <tech>
            <id>11</id>
            ....
        </tech>
    </Category>
    <Category name="Category 2">
        .....
    </Category> 
</FreeOrion::TechTree>
3.) should it be possible to read the <description>-element from a separate language-dependent file? or should the technology-description file itself be language-dependant?

4.) should it be possible to define sub-categories?
if yes how deep? (infinite/restricted depth)

5.) should it be possible to define sub-techs of subtechs?
if yes how deep? (infinite/restricted depth)

6.) should instead of a list of prerequisite techs a list of condition-classes be used to determine visibility and researchability? (would make it much more flexible...)

MisterMerf
Space Squid
Posts: 67
Joined: Sat Oct 02, 2004 3:38 am
Location: Saint Paul, MN (USA)

#2 Post by MisterMerf »

Is there a plan to clearly separate "Theory" tech from "Application" tech? Is it simply implied by subtechs or a lack thereof?

tzlaine
Programming Lead Emeritus
Posts: 1092
Joined: Thu Jun 26, 2003 1:33 pm

Re: Tech XML-Representation Attempt

#3 Post by tzlaine »

LaplaceOperator wrote:Hi

I'm just working on the tech loading code. And i was just wondering if it would be a favorable idea to put the description of the associated effect/effectgroup also into the tech-describing xml file as inline python...
The document structure looks like this so far.
1.) What do you think about the structure? (did i forget something?)
We are going to use the name of the tech as its ID. So we don't want a numeric ID field, and the Tech loader needs to throw an exception if more than one tech has the same name. Eliminating the numeric IDs will make it vastly easier for non-programmers to generate these tech files.

Also, we have three kinds of techs: theory, application, and refinement. You might want to have a Tech subclass for each of these.

You should have a <requires> section that lists all techs that are prerequisites for the current tech, and an <allows> section for all techs that this one unlocks. That would be simplest.

Also note that the tech "tree" is probably really a graph, and may even end up having cycles in it. It all depends on the specific dependencies the designers come up with.
2.) inline python script?
No. We're not using Python for Techs or Effects at this point. Just load the Effects / EffectsGroup using its factory or XML ctor as approriate.

Code: Select all

<FreeOrion::TechTree>
    <Category name="Social Science">
        <tech>
            <id>10</id>
            <name>Mark I</name>
            <description>Powerful solver for social problems (in- and outside the empire)</description>
            <rpperturn>10</rpperturn><!-- RP's needed to advance this project for one turn -->
            <research_duration>20</research_duration><!-- the minimum turns it takes to research it -->
            <vispretech>2, 4</vispretech><!-- list of techs needed to make this one visible in the ResearchScreen -->
            <unlpretech>2, 4, 9, 2</unlpretech><!-- list of techs needed to make this one researchable -->
            <effect>           <!-- inline python-script ??? would be cool -->
            <?pyscript
                dothis(withthis);
                dotthat(withthat);
                etc();
            ?>
            </effect>
            <subtechs> <!-- applied technologies -->
                <tech>
                    ...
                </tech>
                <tech>
                    ....
                </tech>
            </subtechs>
        </tech>
        <tech>
            <id>11</id>
            ....
        </tech>
    </Category>
    <Category name="Category 2">
        .....
    </Category> 
</FreeOrion::TechTree>
3.) should it be possible to read the <description>-element from a separate language-dependent file? or should the technology-description file itself be language-dependant?
We have a string table system for language-dependent text. For name and description, you should just enter [tech name]_NAME and [tech name]_DESCRIPTION, respectively, where [tech name] is the name of the tech in all caps with underscores. Then the appropriate text should be entered in stringtable_eng.txt, stringtable_esp.txt, etc. At XML load time, you should look up the language-dependent value of these strings before placing them into the Tech object.
4.) should it be possible to define sub-categories?
if yes how deep? (infinite/restricted depth)
Categories should only be used for UI enhancement, as far as I can tell, so ask a designer whether the want a certain number of category levels, or arbitrarily many.
5.) should it be possible to define sub-techs of subtechs?
if yes how deep? (infinite/restricted depth)
I don't know what a subtech is, and there shouldn't be any.
6.) should instead of a list of prerequisite techs a list of condition-classes be used to determine visibility and researchability? (would make it much more flexible...)
Currently, the idea for techs being unlocked is that they can only be unlocked by other techs, so no.

LaplaceOperator
Space Squid
Posts: 60
Joined: Wed Sep 08, 2004 3:20 pm
Location: Switzerland

#4 Post by LaplaceOperator »

thanks, for the enlightenment :)

Post Reply