Thrice damned AIWeights!

Koshling

Vorlon
Joined
Apr 11, 2011
Messages
9,254
Ok - turns out a lot of the building choice of inappropriate building (order) is down to AIWeights in the XML. I thought we'd removed all of these a year or two ago except for a very few special cases. Turns out TONS of buildings have them. Basically it invalidates all tuning work on the AI, since they have a larger effect than most any tweaks to the AI will have.

I am going to change the code to utterly ignore them for now, since that will improve the decision making for MOST buildings (but break a few special-cased ones that do need them). Since I was laboring under the misapprehension that the XML wasn't using them apart from a few necessary cases, we'll have to start from scratch retuning the ones that need it, so expect a month or so before we can get the AI back to a sensible build order with a basis where AI tweaks can actually work correctly. I strongly suspect that the things that will break are likely to be buildings built by units (so anything to do with subdued animals, possibly captives, etc.). However, if I don't remove them there is no way to make the AI take its own decisions since the AIWeights are basically overriding them, so this is a necessary first step.
 
I think that the whole concept of AIWeights should be utterly scrapped for now and that this change to ignore them should be permanent. Most of the time I won't even check when making some new XML item to see if it has AIWeights and I suspect others don't either. Making them useless is a great idea which is long overdue.
 
Is this the recent cause for the AI research and religion founding/converting slowdown. Or is that another separate problem?

JosEPh
 
Is this the recent cause for the AI research and religion founding/converting slowdown. Or is that another separate problem?

JosEPh

It's part of it - more that other changes exposed it, but yes it has a lot to do with the poor early research performance.
 
Ok - turns out a lot of the building choice of inappropriate building (order) is down to AIWeights in the XML. However, if I don't remove them there is no way to make the AI take its own decisions since the AIWeights are basically overriding them, so this is a necessary first step.

Now is this ALL the AIWeight in everything, or just certain AI Weights. ie: buildings, units etc??
 
I think that the whole concept of AIWeights should be utterly scrapped for now and that this change to ignore them should be permanent. Most of the time I won't even check when making some new XML item to see if it has AIWeights and I suspect others don't either. Making them useless is a great idea which is long overdue.

They are needed for special-cases (like buildings/outcomes/units whose effects manifest via Python for example), but should always be 0 by default and require justification for any non-0 value. Blanket ignoring them (as I am doing now for buildings at least) will probably screw some things up (bothering to build mater hunter for example as a priority), but until the XML is modified to remove them on all but those special cases there is no way to tell in the code, so a clean slate is a better basis to work from for now. AFTER they are all removed from the XML I'll turn off the blanket ignore again and we can put back the few necessary cases as we (re)identify them, but that process will take time from playing lot of test games to see what the AI does again now that it isn't being polluted by the weights.
 
I think SO makes a good point. Grep/Notepad++ can make the removal of all ai weight xml fairly trivial (sure it'd take a bit to do the work but if that's what's in the way it wouldn't take as long as a major amount of programming - then the xml - then removing that portion of the programming.)
 
They are needed for special-cases (like buildings/outcomes/units whose effects manifest via Python for example), but should always be 0 by default and require justification for any non-0 value. Blanket ignoring them (as I am doing now for buildings at least) will probably screw some things up (bothering to build mater hunter for example as a priority), but until the XML is modified to remove them on all but those special cases there is no way to tell in the code, so a clean slate is a better basis to work from for now. AFTER they are all removed from the XML I'll turn off the blanket ignore again and we can put back the few necessary cases as we (re)identify them, but that process will take time from playing lot of test games to see what the AI does again now that it isn't being polluted by the weights.

Could we make a script (or write a .NET program) to go through all of the XML and set all AIWeight tags to 0 and then go and manually change only the ones which are needed?
 
Could we make a script (or write a .NET program) to go through all of the XML and set all AIWeight tags to 0 and then go and manually change only the ones which are needed?

If you know how to make a script go ahead, but i planned on working on it tonight already around mid-night or so, so pls let me know thx.
 
I'm not a scripter but lol... that would be pretty fast to do it that way if the scripting was quick enough to write.

I'm thinking I might be able to piggyback it on Koshling's scanner tool (if I can remember where I put the source for that :rolleyes:). Instead of scanning and making output data it could scan and replace all AIWeights with 0 if they aren't 0 already.
 
I'm thinking I might be able to piggyback it on Koshling's scanner tool (if I can remember where I put the source for that :rolleyes:). Instead of scanning and making output data it could scan and replace all AIWeights with 0 if they aren't 0 already.

That'd certainly be a cool trick. Good luck on that!
 
Since the XML is all over the place it also means that the script can be not run on those parts that have the aiweights because they are python eg Vokarya's wonders are almost all python so if you remove the AIWeights from them we would only need to put them back again.
 
Not really, it can find and replace stuff (which I use extensively), but if you have dozens of possible AIWeights that doesn't work too well.
It works, if you use regular expressions.
You want to replace this:
<iAIWeight>[^<]*</iAIWeight>
with
<iAIWeight>0</iAIWeight>
 
It works, if you use regular expressions.
You want to replace this:
<iAIWeight>[^<]*</iAIWeight>
with
<iAIWeight>0</iAIWeight>

Great, I didn't know NP++ supported regular expressions. Thanks, I'll go and try that for buildings and units.

@DH & Hydro: When I commit this I'll leave out Vokarya's stuff but the absolutely essential AIWeights in other parts (IE, Master Hunter) need to be redone.
 
Back
Top Bottom