Logo Platform
logo amplifiers simplified

AI Modding

Reply
Copied to clipboard!
12 years ago
Aug 11, 2012, 3:01:07 PM
CaptainPsilon wrote:
What i am saying that all AI behavior hardcoded and modding is impossible. period. You can play with these meaningless numbers in xml but it changes almost nothing.


It is possible to improve AI behavior with modding, and I have proved it. I have significantly improved the AI behavior by changing building prerequisites. It remains to be seen how much else can be improved with xml. I agree that "not everything" can be improved in the xml. Also, these experiments are useful even if modders cannot fix them. There are several specific places (hissho early game AI, retrofitting) where players have demonstrated that the AI is poor, and the development team has fixed it.



seanw3 wrote:
Since you brought up the C# stuff, will that work with the current modding system?


Legally, the development team has only granted access to the galaxy generator C# code, which you can find in the thread "galaxy generator explained". Not related to AI. As you may know, "a few" game companies have released more of their C/C++/C# source code for modders to work on, but there is no indication whether Amplitude will release their AI source code.
0Send private message
12 years ago
Aug 11, 2012, 3:23:18 PM
CaptainPsilon wrote:
What i am saying that all AI behavior hardcoded and modding is impossible. period. You can play with these meaningless numbers in xml but it changes almost nothing.


That actually is not true!



Have you even had a look at what the XML-Files offer?



Stuff like: "$(../TraitEconomy07Norm1) or (($(../ClassEmpire:NumberOfFriends) ge 1) and ($(ClassStarSystem:TradeRoutes) ge $(ClassStarSystem:MaxTradeRoutes)))"

You can actually impement formulas, comparisons, connect them with and/or ... as if you were actually coding. I think there is a lot of potential in those XML-Files to be uncovered and put to use.

The example shows how the AI is told to only build trade-improvements if it actually can trade, has at least one friend and is not maxed out on trade-routes-yet.



How can I upload XML-Files here? I finished editing the Hero-File. The assingment in the original was terrible. 15 for system, 15 for fleet then 15 for system again... Totally random. So roundabout half of the heroes without this fix are completely wrong when it comes to assignment to either fleets or star-systems.
0Send private message
12 years ago
Aug 11, 2012, 3:36:57 PM
Ail wrote:
How can I upload XML-Files here?


Zip it, then attach to a post. Please see the sticky welcome thread in the tech support forum if you need more details.



Do you mind if I include your change into the community bug fix / balance mod? Of course I will add your name to the credits.
0Send private message
12 years ago
Aug 11, 2012, 4:04:36 PM
davea wrote:
Zip it, then attach to a post. Please see the sticky welcome thread in the tech support forum if you need more details.



Do you mind if I include your change into the community bug fix / balance mod? Of course I will add your name to the credits.


Not at all. But I haven't actually tested if it works yet.

Whoever uses it shall observe if he can still see the AI using heroes that are clearly designed as system-heros on their fleets.

Don't know if there also is a way to see what Heros they assigned to their systems.
AIParametersHero.zip
0Send private message
0Send private message
12 years ago
Aug 11, 2012, 4:27:43 PM
A question: Does anyone know what exactly:







1



from Personality.xml does? It sounds like it could have huge impact on how the AI attacks but maybe this assumption is wrong.
0Send private message
12 years ago
Aug 11, 2012, 7:45:18 PM
Ail wrote:
Don't know if there also is a way to see what Heros they assigned to their systems.


I will try it, but first I have to get my unmodded "fast science" victory. Are you aware of "jailbreaking"? Once you edit the save game, you can open it as any AI. This lets you see where that AI has assigned its heroes. Details here:



http://forums.amplitude-studios.com/showthread.php?2131-!!-able-to-rejoin-game-as-any-ai-player-!!
0Send private message
12 years ago
Aug 11, 2012, 9:59:55 PM
Thanks. Sounds like a really nice way to test how the changes work.



Now in your Mod you use "$(ClassStarSystem:Population)" Is there also a Variable for the Max-Population of that system?

If that's the case one could set up a formula that determines the value of food-improvents depending on the discrepancy of existing population vs. max-population.



Something along the lines of that:











(300 being the cost of StarSystemImprovementFood3)











If that is possible the AI could be tought to value food more if there is a lot of pop missing and value it far less the closer it is to max.

The $(ClassStarSystem:Industry) / Building-Cost should also be factored in as it basically defines the building-time and thus priorizes cheaper improvements over more expensive ones with similar effect.
0Send private message
12 years ago
Aug 11, 2012, 10:34:32 PM
I believe "$(ClassStarSystem:MaxPopulation)" will give the max pop. The equation you give sounds interesting. I think it could work. Now if only there were a way to scrap these buildings once they are no longer needed; but I think that will take dev team action.
0Send private message
12 years ago
Aug 12, 2012, 4:30:52 PM
Ail wrote:
Not at all. But I haven't actually tested if it works yet. Whoever uses it shall observe if he can still see the AI using heroes that are clearly designed as system-heros on their fleets.


I have incorporated this into my local version of the community mod, and at least verified the game starts up with it. I will try to get time to play a game today and then look into the AI selections.



I loaded a couple of previous save games with no mod, and looked at the AI hero behavior. I always pick whether a hero will be a fleet hero or system hero. Some class combos are purely one or the other (commander/pilot and admin/corporate). Some class combos are hybrid. If I have a hybrid hero and I use it as a fleet hero, I only pick abilities from the fleet class.



What I observe is that the AI will split abilities for a hybird hero, but not 50/50. Maybe it picks based on a ratio of the related stats? Ie a corporate/pilot with wit 4 and offense 1 would choose 80% corporate abilities. Anyway a lot of the fleet heroes were 50/50 with system abilities, which seems like a waste. Do you think there is a way to affect that for hybrid heroes? Maybe if you have picked the assignment carefully for hybrid heroes, it will be "less".



Also, I found several games where heroes were left as injured even though the AI had enough dust to heal them, and several cases where heroes were "unassigned", just sitting in the academy. This is always a waste. I did not count how often this happens but any nonzero number is a problem. Not sure if modding can help this either.
0Send private message
12 years ago
Aug 13, 2012, 2:24:37 AM
I've been testing a lot the whole day as well.

I've tested two things: 1st was hero-assignement and 2nd was what would happen when I change "" from Personalities.xml.



The assignement seems to have worked as I intended it to. However, I have not done that jailbreak thing so I could not see how they distribute skill-points to the heroes.

I think it is a weighted randomization as in AIParametersHeroAbility.xml.



For Example:



HeroAbilityCommon01 is the 1 for all thing. According to that:



















There is a chance the AI will get it. The Highest chance is when the Hero is an Adventurer.

I guess that for Hybrids the Chance the AI will skill into both paths is really high as it apperantly only looks at the Hero-Classes and not what role it has assigned it to and how the base-values look like.

Can't really think of a way to fix this other than editing the heroes themselves and avoiding hybrids there.

It might also be considerable to allow the AI to use hybrid heroes for both but I think that will not really help the AI to become better in that regard since specialization is just so much more effective.



To the other thing I tested.



In the first test I changed

1

to

10

and played a game on "Serious"-Difficulty.



It might have done exactly what I intended it to do. But then again it might be possible that it would do that anyways since the patch as I have not tested the behaviour without it specifically. Maybe someone who just plays the game often can say if the following behaviour is true anyways or if the change might have caused it:



I've seen many occassions where the AI would send a large number of fleets at once to several systems.

For example the cornered Sophons declared war on me and sent 5 fleets to both of the planets they could reach. They did not keep anything worth to mention at home. And then split up their forces to try and conquer several systems at once.



I remember a behaviour where the AI in war-times would be very passive and only attacked with one fleet at a time. This was not the case here.



In the next test-game I set the value to:

$(ClassEmpire:CommandPoint)

because "10" could under some circumstances still be to low. I don't know what the value really stands for afterall.



I suppose $(ClassEmpire:CommandPoint) is the amount of total-command points an empire has. But might be wrong there.



The game was not very good to see if it worked because I was too weak because of a terrible starting-location. In the war I declared on the Horatio they were too advanced but did not really use a whole lot of fleets to kill me because their few fleets where enough.



I had a system they could not reach and I could keep all game long. (The other AIs really seem to leave you alone when you are one of the weakest).

Near the end they attacked with one fleet but I could repel it and they never sent more because they were being wiped out by another AI at that time.

I've gotten the best sensors I could to observe as much as possible.



The AIs really were throwing fleets at each other wildly and none of them seemed to have a huge stock. Systems switched owners back and forth between 3 races. Actually I'm not even sure it should always use everything instead of holding back a little. Maybe one can make it behave differently depending on the number of wars it has. If it only has one, I see no reason to hold back. If it has several it probably should play more defensive.



I need to know more about the syntax that is allowed here.



Something like "$(ClassEmpire:NumberOfWars) gt 1?1smiley: embarassement(ClassEmpire:CommandPoint)" that is not a wild mix of bash-scripting and C++ but actually does what I want.



The next thing I will be doing is using the "StarSystemImprovement.xml" from the community-mod and try to use some actual calculations to determine some more of the AIPathsPrerequisites.

Not just saying "If I have more than 50 Industry I'll build it" but more like:



For example: If the expected F/I/D/S-gain divided by the production-cost multiplied by the Industrial-capacity is greater 1, then build it.



Determining the FIDS-Gain can be tough though.



When StarSystemImprovementMoney1 costs 75 to build and gives 1 money/pop for the Tier 1 and 2 planets, I would have to count the pop on those planets, substract 2 (the upkeep) divide by 75 and then multiply by production.



Say I have 6 population affected by it, that means I would have an overall benefit of 4 fids.

Then I would only build it if I had at least 18.75 production.



Well, gotta see if it works.
0Send private message
12 years ago
Aug 13, 2012, 12:21:33 PM
I've got good and a not so good news:



Good: The restrictions in also work for the AI-governors you can assign. This makes it really easy to test.

Not so good: Obviously you can screw up the syntax big time without the game giving any notice.



For Industry 2 I tried the following:



$(ClassStarSystem:Industry) * 0.2 + $(ClassStarSystem/PlanetTypeTundra,Population) + $(ClassStarSystem/PlanetTypeDesert,Population) + $(ClassStarSystem/PlanetTypeArctic,Population) + $(ClassStarSystem/PlanetTypeLava,Population) * 2 - 3 gt 200 / $(ClassStarSystem:Industry)



I don't even know if "$(ClassStarSystem/PlanetTypeTundra,Population)" does anything and if I can use all those fancy operators. I just can see that the AI won't build this building despite due to my calculations it should.



I had a system that had 1 Pop on Tundra and 35 Production.

Since 35*0.2 + 1 - 3(=5) is less than 200/35(=5.7) it was fine that it wouldn't build it.

Now the Pop on the Tunra grew to 2 and the Production to 42.

42*0.2 + 2 - 3(=7.4) infact is more than 200/42(4.8) but the governor still won't build it.



I'd love if someone from Amplitude could give some insight here. You should see what I'm attempting to do and probably know the syntax that makes it work.
0Send private message
12 years ago
Aug 13, 2012, 12:56:19 PM
You are doing a great job. I have no idea what i am doing is the best way to improve an AI. This is the actual way majority of AI developers prefer. Keep it up. Thumb up.



0Send private message
12 years ago
Aug 13, 2012, 1:43:56 PM
Actually it's pretty straightforward. Every player thinks something when he does something in a game. When programming an AI, what you do is finding ways of defining what you would do and then tell it to the Computer.



My problem here is: I know what I want to tell him but I don't know how because the XML-Programming-Interface is not documented well enough.

If I can get one working example for stuff like what I posted above, I think I can drastically improve the AI when it comes to if and when to build what in it's systems.



The reason why the AI does perform so poorly right now is mainly because it lacks knowledge. There is a file called "AIParametersBuilding.xml". It defines how much the AI will want to build what building. But all the values there are static. For example all Money-Improvements are marked with a Value of 2. So whenever the AI thinks it needs more money it will just build all of them without any thoughts if the amount gained compared to the production-cost and maintenance is actually worth it.



As a modder you have 2 ways to affect it.

in "StarSystemImprovement.xml" allows you to set conditions for the AI to not build a building at all.

And then by changing the Values in "AIParametersBuilding.xml" you can also modify the order in which the AI builds stuff. So if 2 buildings both are qualified it should also matter which one to build first.



Btw. the reason why the AI always sets the specialization of all planets to the same value is because all specializations have hard values (2.1 - 2.3) and not calculated ones (1 - 6). And they are all the same for the same Tier. It could easily be made aware that Factories on a Desert are way less effective than on a Lava-Planet.
0Send private message
12 years ago
Aug 14, 2012, 9:50:59 PM
@ ail, I tested the AIParametersHero.xml you attached in post #24, after adding the other parameters files to my mod. Good news, it worked fine. Bad news, I am not really sure how to evaluate how much improvement it gave. I looked at all the AI players in the game. I didn't find any case where a "pure" hero was attached to the wrong type (ie corp/admin on a fleet). But, many of the heroes are hybrid anyway, and who is to say which is right? Almost all the heroes were attached to fleets. The hybrid heroes had an assortment of fleet abilities and system abilities. Personally, I would have had more system heroes, and I would not have any mixed abilities in one hero. I am not sure how to affect that with modding.



Anyway, it can't hurt, and I will include your file into the next release of my community mod.
0Send private message
12 years ago
Aug 15, 2012, 10:51:11 AM
davea wrote:
But, many of the heroes are hybrid anyway, and who is to say which is right? Almost all the heroes were attached to fleets.


In case of Hybrid-Heros I based the decision on the Starting Values.

For Example a Corporate/Adventurer with

8 Int

2 Off

3 Deff

would be considered "System"

But the same with

5 Int

4 Off

4 Deff

would be considered "Fleet"



davea wrote:


The hybrid heroes had an assortment of fleet abilities and system abilities.

Personally, I would have had more system heroes, and I would not have any mixed abilities in one hero. I am not sure how to affect that with modding.



I see that as a big problem aswell. I have an idea how to deal with it but that would require that all-hybrids are considered 1 group.

In one of the Files there are numbers attached to each hero-ability and how likely it is that a specific type would get these.



Now if we say that every Hybrid is a System we could set the likelyhood of non-system abilities for Admin/Corp to 0 and reduce the likelyhood for Non-Admin/Corp to get their stuff to really low values like 0.1 but also reduce the likelyhood for them to get Admin/Copr-Stuff to 0.



When it works like I think it would go like this:



AI has a levelup on say Corp/Adventurer. It now looks at the likelyhood-file and finds:

The Corp side of it wants: 2 for Corp-Stuff 1 for Admin-Stuff 0.1 for Hybrid Stuff 0 for rest

The Adventurer side wants: 0.1 for Hybrid-Stuff, 0.1 for Off/Deff-Stuff 0 for rest

If it's added up then this guy should have a very much higher likelyhood to get the system-stuff.

When it is a pure-fleet hero 0.1 is still much higher than 0 and he will still pick his fleet-stuff.

I think I'm gonna try this out. But forcing the AI to use all hybrids as System-Heros might result in the AI having too few heros left for fleets. We'll see.



Another thing I think can change without a lot of trouble is some more and easy to implement restrictions in the StarSystemImprovements.xml.



Here is what I specifically think about:

Colony-Bases. The AI builds them when it feels like it. I think it is not efficient to do so unless the already colonized planets reached their population cap.

So putting in

$(ClassStarSystem:Population) eq $(ClassStarSystem:MaxPopulation)

shall realize that.

Same goes for the Pop-Cap-Boosters.



The other thing is the specialization of the planet. I think not using the Farming-Improvement when Max-Population has not been reached is a bad thing to do and could be prevented my making MaxPopulation a requirement for the other improvements.



Would everyone agree on these points or has someone a reason for why that could probably make the AI worse?



(Actually I would allow the Pop=MaxPop things also at Pop=MaxPop-1 but I still don't really know how to realize that without the ability to perform operations here or reading the values of self-defined-variables.)
0Send private message
12 years ago
Aug 15, 2012, 12:26:02 PM
Wouldn't it be just easier to change heros and heroskills and make just 2 group of heroes. Fleet and System heroes. Others could access to all fleet skills and others to all system skills?

This would also mean that no matter what, system hero most likely would have useful skills as would fleet hero too.



It needs bit work 1-2 hours but after that it should work perfectly well.





And no, I can't do it, I'm bit too busy with endless dream mod smiley: smile
0Send private message
12 years ago
Aug 15, 2012, 2:01:22 PM
Of course it would be easier to do and especially easier to be sure of it working as one intends.



But the goal of my mod was more or less improving the behaviour of the AI without changing anything that affects the player.



I think every player will consider the Hybrid-Heroes as Sub-Par anyways and would actually like to have a clear separation.

But as of yet it's just a part of the game that these exist and player, as well as AI, have to cope with it.



And when I can change how the AI copes with it, without changing anything for the player, then that would be my favourite.



However, there's one excetption to that. Retreating. As long as the AI can't do that, I find the player shouldn't be able to do it either. So removing it from the arsenal of cards is the only way of leveling the playing-field in this regard.



But I will do that as one of the last things because I'm putting my hopes into Amplitude fixing it sooner or later.
0Send private message
12 years ago
Aug 15, 2012, 2:17:34 PM
Ail wrote:
Here is what I specifically think about: Colony-Bases. The AI builds them when it feels like it. I think it is not efficient to do so unless the already colonized planets reached their population cap. So putting in

$(ClassStarSystem:Population) eq $(ClassStarSystem:MaxPopulation)

shall realize that. Same goes for the Pop-Cap-Boosters.


Good suggestion for pop cap boosters. I didn't realize that expanding to another planet in the same system was decided just like any other improvement; there "should be" some term about how much happiness will change based on planet type and access to a luxury. For example, could you really prevent expansion to a second planet (just as a test) by setting the prerequisite to "industry lt 0"? I know this works because I modded the sensor range improvements like this and the AI stopped building them.
0Send private message
12 years ago
Aug 15, 2012, 2:18:54 PM
Ail wrote:


But the goal of my mod was more or less improving the behaviour of the AI without changing anything that affects the player.



I think every player will consider the Hybrid-Heroes as Sub-Par anyways and would actually like to have a clear separation.





One could argue that making better AI affects to players smiley: biggrin



To later:



I really wish that we would be more dedicated modders in these forums, this would be wonderful idea for mod... and even better plugin for any bigger mod.



Sadly most of our existing modders are already doing something important.
0Send private message
?

Click here to login

Reply
Comment