XML downside

For what's not in 'Top Priority Game Design'. Post your ideas, visions, suggestions for the game, rules, modifications, etc.

Moderator: Oberlus

Current FO XML vs SE4 TXT techs: who wins?

FO XML are ok, I understand them.
17
77%
KISS. Go for TXT.
5
23%
 
Total votes: 22

Message
Author
drek
Designer Emeritus
Posts: 935
Joined: Thu Jun 26, 2003 8:07 am

#16 Post by drek »

hrm,

It's the conditions and gadzillion tags that really make the Tech.xml hard to read.

Code: Select all


<tech>
  Name=LEARN_DREK_TUTORIAL
  Description=LEARN_DREK_TUTORIAL_DESC
  Type=TT_APPLICATION
  Category=LEARNING_CATEGORY
  Research_cost=10
  Research_turns=5
  <prerequesite>LEARN_THEORY_OF_DREK</prerequesites>
  <EffectGroup>
   ActivationCondition="Self"
   ScopeCondition= "EmpireAffilation=Source.Owner && PopulationCenter=True && (FocusType=PrimaryResearch || FocusType=SecRessearch)" 
   StackingGroup=STACK_DREK_TUTORIAL
       <Effect::SetMeter>
          meter=Meter_Research
          value=Target.MaxResearch+2
          max=1
       </Effect::SetMeters>
     </EffectGroup>
</tech>

Dreamer
Dyson Forest
Posts: 228
Joined: Sun Mar 13, 2005 6:44 am
Location: Santiago, Chile

#17 Post by Dreamer »

Well. Then the problem is not actually that XML is bad bud that FO-XML is bad. In proped XML atributes that appear only once should be just that, atributes, and not yet another level of tags. As far as I know XML (and I'm not a guru, neither a newbie) it goes like this:

Code: Select all

<tag atribute1="value" atribute2="value"...>
   <othertag>
   <othertag>
       <optional tag> // with more possible subchilds.
   </othertag>
</tag>
for example:

Code: Select all

<Tech>
      <name>LEARN_DREK_TUTORIAL</name>
      <description>LEARN_DREK_TUTORIAL_DESC</description>
      <type>TT_APPLICATION </type>
      <category>LEARNING_CATEGORY</category>
      <research_cost>10</research_cost>
      <research_turns>5 </research_turns>
      <prerequisites>
          <prereq>LEARN_THEORY_OF_DREK</prereq>
      </prerequisites>
      ...
</tech>
should be:

Code: Select all

<Tech
      name="LEARN_DREK_TUTORIAL"
      description>LEARN_DREK_TUTORIAL_DESC</description>
      type="TT_APPLICATION"
      category="LEARNING_CATEGORY"
      research_cost="10"
      research_turns="5"
>
      <prereq>LEARN_THEORY_OF_DREK</prereq>
      ...
</tech>
You only need as many tags as posible nodes in a tree. Never a tag for a single atribute.

noelte
Juggernaut
Posts: 872
Joined: Fri Dec 26, 2003 12:42 pm
Location: Germany, Berlin

#18 Post by noelte »

If not using attributes is the only concern, easy to fix....
Press any key to continue or any other key to cancel.
Can COWs fly?

Daveybaby
Small Juggernaut
Posts: 724
Joined: Mon Sep 01, 2003 11:07 am
Location: Hastings, UK

#19 Post by Daveybaby »

I'm not up on current status of XML apps, but it occurs to me that there MUST be some freeware or OS app out there which imports an XML structure and presents you with a simple database front end to let you edit/populate fields, then spews out more XML at the end.

If there isnt, somebody should write one. Now. (not me though i cant be bothered).
The COW Project : You have a spy in your midst.

Tyreth
FreeOrion Lead Emeritus
Posts: 885
Joined: Thu Jun 26, 2003 6:23 am
Location: Australia

#20 Post by Tyreth »

When someone puts in the effort, we'll probably have a GUI based tech tree editor. I was considering making one myself as an exercise to learn python, but that hasn't happened yet :)

drek
Designer Emeritus
Posts: 935
Joined: Thu Jun 26, 2003 8:07 am

#21 Post by drek »

noelte wrote:If not using attributes is the only concern, easy to fix....
The attributes as xml attributes rather than seprate tags would be nice, for readability. But:

The condition statements are murder, in reading, writing, and debugging. Dave's off-the-shelf XML editior wouldn't help much.

I've written a two or three parsers for text adventures (in higher level languages). In theory, thanks to regular expression libraries, it should be pretty easy for me to tap out a condition statement parser (and even a effect statement parser).

In practice, I hate C++, just the thought of touching it makes me lazy. The gods willing, one of these days I'll get off my ass and change the tech parsing code so that it can read conditions like this:
ScopeCondition= "EmpireAffilation=Source.Owner && PopulationCenter=True && (FocusType=PrimaryResearch || FocusType=SecRessearch)"
instead of like this
<scope>
<Condition::And>
<Condition::EmpireAffiliation>
<empire_id>Source.Owner</empire_id>
<affiliation>AFFIL_SELF</affiliation>
<exclusive>1</exclusive>
</Condition::EmpireAffiliation>
<Condition::Type>OBJ_POP_CENTER</Condition::Type>
<Condition::Or>
<Condition::FocusType>
<primary>1</primary>
<FocusType>FOCUS_RESEARCH</FocusType>
</Condition::FocusType>
<Condition::FocusType>
<primary>0</primary>
<FocusType>FOCUS_RESEARCH</FocusType>
</Condition::FocusType>
</Condition::Or>
</Condition::And>
</scope>
As it stands, writing out and debugging conditions is a massive time sink.

Dreamer
Dyson Forest
Posts: 228
Joined: Sun Mar 13, 2005 6:44 am
Location: Santiago, Chile

#22 Post by Dreamer »

ScopeCondition= "EmpireAffilation=Source.Owner && PopulationCenter=True && (FocusType=PrimaryResearch || FocusType=SecRessearch)"
Sound a lot like SQL. But with '&&' intead of 'AND'. Maybe there is a free SQL parser we could reuse?
Last edited by Dreamer on Wed May 11, 2005 7:07 pm, edited 1 time in total.

User avatar
yaromir
Space Kraken
Posts: 101
Joined: Thu May 05, 2005 8:30 pm
Location: New York City

#23 Post by yaromir »

why not use an automated Scanner-Parser generator based on grammar?

I am not all that versed in these technologies, but writing out grammar was a hell of a lot easier than coding scanner and parser from scratch.
Staying awake and aware is perhaps the hardest thing to do.

drek
Designer Emeritus
Posts: 935
Joined: Thu Jun 26, 2003 8:07 am

#24 Post by drek »

yaromir wrote:why not use an automated Scanner-Parser generator based on grammar.
Overkill. Scanner-Parser generator is meant for building compilers/interpertors.

The task is relatively easy, it's just a matter of buckling down and doing it. I'm not really in a buckle down mood right now, esp. since are talking about slogging through C++ code.
Sound a lot like SQL
Too much work, unless the game has a full fledged relational database. It doesn't.

Yoghurt
Programmer
Posts: 376
Joined: Sat Jun 28, 2003 8:17 pm
Location: Heidelberg, Germany

#25 Post by Yoghurt »

Just for the record; as soon as I have time, Python support will be in and I will provide an alternative Effects/Tech system based on Python scripts. When these are in, we can compare which system is better suited.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

#26 Post by Geoff the Medio »

Yoghurt wrote:Just for the record; as soon as I have time, Python support will be in and I will provide an alternative Effects/Tech system based on Python scripts. When these are in, we can compare which system is better suited.
I strongly suggest you not waste your time rewriting the effects and tech system. Though it may not be ideal, what we have now works, we don't *need* another one, mvor has started writing an editor for effects that will help with the (IMO very exaggerated and overstated) difficulty in writing effects, and there are lots of other things we do and will need, including everything to do with ships and combat.

Yoghurt
Programmer
Posts: 376
Joined: Sat Jun 28, 2003 8:17 pm
Location: Heidelberg, Germany

#27 Post by Yoghurt »

Geoff the Medio wrote:I strongly suggest you not waste your time rewriting the effects and tech system. Though it may not be ideal, what we have now works, we don't *need* another one, mvor has started writing an editor for effects that will help with the (IMO very exaggerated and overstated) difficulty in writing effects, and there are lots of other things we do and will need, including everything to do with ships and combat.
The implementation of the Effects system is a test for the Python integration. I find it more useful to do that, than to write 500 different unit testcases that noone will ever need again. Besides that, I will have more time to spare than I want in the next few months.

Impaler
Creative Contributor
Posts: 1060
Joined: Sun Jun 29, 2003 12:40 am
Location: Tucson, Arizona USA

#28 Post by Impaler »

I'm takeing a class on XML, and I agree that what we have so far is sub-optimal, the readability needs to go up quite a bit. Making most of the data a atributes would be a good start. But we can go even further. For one thing Tech_Catagory and Tech_Type should be higher level elements something along the lines of...

<Tech_Catagories>
<Learning>
<Theories>
<Tech></Tech>
<Tech></Tech>
<Tech></Tech>
</Theories>
<Aplications>
<Tech></Tech>
<Tech></Tech>
<Tech></Tech>
</Aplications>
</Learning>
<Another_Catagory></Another_Catagory>
<Yet_another_Catagory></Yet_another_Catagory>
</Tech_Catagories>


That would knock out 2 whole atributes AND make is simple and easy to move techs from one group or type to another by Cutting and Pasting. Also I am wondering is we have any kind of Schema for the document to Validate it. Their are all kind os illogical things people could do when moding the thing, for one we should make shure that all Pre-requisites are infact other tecnologies and enshure all data is of the proper type. It would save the programers from having to do as much validation and the standards could be changed and update more easily.
Fear is the Mind Killer - Frank Herbert -Dune

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

#29 Post by Geoff the Medio »

Impaler wrote:I'm takeing a class on XML
So are you getting a degree then? Where did you end up going?

In general, I agree that the current layout of techs.xml isn't very good... However tzlaine doesn't seem very interested in rewriting it for just that reason, or to deal with other relatively minor issues like it crashing without usable error if you put a space before the opening < on the first line. He does have more important things to work on though, so I don't image it will change unless you want to fix it yourself...

Impaler
Creative Contributor
Posts: 1060
Joined: Sun Jun 29, 2003 12:40 am
Location: Tucson, Arizona USA

#30 Post by Impaler »

Yes, I thought yall knew (sorry I must have forgoten to tell you)

I am going to my local Comunity College http://www.Pima.edu persuing a 2 year Asosiate degree in Computer information Science ( I will probably be able to graduate sooner though because I can count some of my older University of Arizona Ged Ed stuff ). I took Introductory classes last semester (all stuff I knew already) and am now doing Assembly, C and XML. After that I will look to get a Batchlors degree idealy from the University of Advanced Tecnology (a Game oriented schoool ) in Tempe which is just 3 hours away in Phiniox.


As for the XML I think I will start playing around with it, it will be good practice and I might be able to make some improvments. Ware can I find more information on the current state of Techs.xml and how its used by FO? I will have to brush up quite a bit on the Effects and Scopes as well. I imagine most of the changes I have in mind would require re-doing the code that interprits the document in question? I can handle the XML end is someone is able to write new interfacing code (or can give me some pointers on writing such code myself, I am still clueless as to how the XML data realy gets parsed and interprited into the program at run time).
Fear is the Mind Killer - Frank Herbert -Dune

Post Reply