Page 2 of 3

Posted: Tue May 10, 2005 3:48 am
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>

Posted: Tue May 10, 2005 7:49 pm
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.

Posted: Wed May 11, 2005 6:52 am
by noelte
If not using attributes is the only concern, easy to fix....

Posted: Wed May 11, 2005 8:03 am
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).

Posted: Wed May 11, 2005 9:31 am
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 :)

Posted: Wed May 11, 2005 3:54 pm
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.

Posted: Wed May 11, 2005 6:07 pm
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?

Posted: Wed May 11, 2005 6:36 pm
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.

Posted: Wed May 11, 2005 10:11 pm
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.

Posted: Fri Jun 10, 2005 7:21 pm
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.

Posted: Fri Jun 10, 2005 7:38 pm
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.

Posted: Sat Jun 11, 2005 11:51 am
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.

Posted: Sat Jun 18, 2005 12:38 am
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.

Posted: Sat Jun 18, 2005 1:20 am
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...

Posted: Sat Jun 18, 2005 3:26 pm
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).