Strategic AI Mod

A place for discussion of making game modifications.
zolobolo
Posts: 910
Joined: Fri Nov 25, 2016 3:49 pm

Re: Strategic AI Mod

Postby zolobolo » Sun Apr 22, 2018 11:07 am

In Vanilla, the AI has thus far been avoiding the construction on Marauders (Gremak specific ground unit), Assault Marines (Human specific ground unit) and Stargates (even AI playing Imperials does not build them)

Do you think the modded construction logic could trigger production of these units as well?
I know this wouldn't result in the AI properly utilizing them (that would probably concern the movement logic) but at least they could have a passive effect on their playstile

According to the production selection logic, I would suppose, that the AI does not have any "plan" for which these elements would be used that is why it is avoiding them completely (no raiding intent on a strategic level means no raiding unit is needed)
Last edited by zolobolo on Sun Apr 22, 2018 6:36 pm, edited 1 time in total.

User avatar
harpy eagle
Posts: 276
Joined: Sat Mar 10, 2018 3:25 am

Re: Strategic AI Mod

Postby harpy eagle » Sun Apr 22, 2018 6:26 pm

zolobolo wrote:Do you think the modded construction logic could trigger production of these units as well
I know this would result in the AI properly utilizing them (that would probably concern the movement logic) but at least they could have a passive effect on their playstile

That's something I'll think about. But yeah, the value of that might be diminished if the AI just treats them like regular ground units.

User avatar
sven
Site Admin
Posts: 1390
Joined: Sat Jan 31, 2015 10:24 pm
Location: British Columbia, Canada
Contact:

Re: Strategic AI Mod

Postby sven » Mon Apr 23, 2018 12:41 am

harpy eagle wrote:The AI now decides to city plan or manufacture population if doing so would produce more resources than building an improvement.


This is a fun feature, but, it can currently trigger bugs due to a bug in my code. Um, at the top of production.lua::deactivate_current_project(planet), there should probably be a call to reset_food_caches(). (This silly explicit cache maintenance is the source of so many bugs, I'm getting really tempted to redesign it somehow.)

zolobolo
Posts: 910
Joined: Fri Nov 25, 2016 3:49 pm

Re: Strategic AI Mod

Postby zolobolo » Mon Apr 23, 2018 5:38 pm

Here is the save for the Gremak survivalist AI mentioned in the other Thread:
https://www.dropbox.com/s/fbcglyngz7gcy ... g.rar?dl=0

What is interesting here is that the AI has made very good decisions so far: conserving forces and building escort ships
At this point in time it has a good amount of resources and good income but has now decided to only build:
1. Transport (though pool is fully utilized)
2. Scout Cruiser (the classical :))

In my opinion, in this scenario, planet: Naradh should construct a Shipyard (as enough metal deposits are in place) and then focus on constructing combat ships. The other planet should focus on refitting the existing ships to the latest design though this would involve movement orders as well so is outside of the scope of this mod

User avatar
harpy eagle
Posts: 276
Joined: Sat Mar 10, 2018 3:25 am

Re: Strategic AI Mod

Postby harpy eagle » Mon Apr 23, 2018 10:33 pm

Thanks, I'll take a look at it tonight.

User avatar
harpy eagle
Posts: 276
Joined: Sat Mar 10, 2018 3:25 am

Re: Strategic AI Mod

Postby harpy eagle » Mon Apr 23, 2018 11:34 pm

zolobolo wrote:At this point in time it has a good amount of resources and good income but has now decided to only build:
1. Transport (though pool is fully utilized)
2. Scout Cruiser (the classical :))


Okay, so (1) is the vanilla AI. I haven't really changed how the AI decides to build transports, outpost transports, or colony ships (aside from a few tweaks, and only for colony ships).

As for (2), what was happening was that the AI decided it wanted 5 scouts, but only had 3.

It looks like the second most desired ship was heavy cruisers, so it probably will return to building those once the scouts are done. While nothing here seems particularly amiss, I've gone and tweaked the scout desire anyways.

User avatar
harpy eagle
Posts: 276
Joined: Sat Mar 10, 2018 3:25 am

Re: Strategic AI Mod

Postby harpy eagle » Mon Apr 23, 2018 11:54 pm

Update (13edc0a): The AI will now move population between worlds if doing so would increase the population cap of the destination world and doing so would leave at least 1 pop of that species left on the source world.

User avatar
harpy eagle
Posts: 276
Joined: Sat Mar 10, 2018 3:25 am

Re: Strategic AI Mod

Postby harpy eagle » Tue Apr 24, 2018 1:48 am

sven wrote:
harpy eagle wrote:The AI now decides to city plan or manufacture population if doing so would produce more resources than building an improvement.


This is a fun feature, but, it can currently trigger bugs due to a bug in my code. Um, at the top of production.lua::deactivate_current_project(planet), there should probably be a call to reset_food_caches(). (This silly explicit cache maintenance is the source of so many bugs, I'm getting really tempted to redesign it somehow.)

Hmm, yes I see. The AI thought it was starving when really it just needed to stop city planning, and ended up with a huge surplus of food from extra unneeded farms several turns later.

Also, I've been trying out your dynamic dispatch fix and it seems to improve things quite a bit. Now when I hack the AI's ship desire to absurdly high levels, it does indeed try to build ships on every single world. I probably now need to be careful that the AI doesn't go overboard on ships, but it's a step in the right direction :D

User avatar
sven
Site Admin
Posts: 1390
Joined: Sat Jan 31, 2015 10:24 pm
Location: British Columbia, Canada
Contact:

Re: Strategic AI Mod

Postby sven » Tue Apr 24, 2018 4:17 am

harpy eagle wrote:Update (13edc0a): The AI will now move population between worlds if doing so would increase the population cap of the destination world and doing so would leave at least 1 pop of that species left on the source world.


I'm a big fan of this change. The population transport feature in r22231 (now on 'in_development') is a descendant of this code. (The list of code diffs relative to your version is rather long, but, basically, the big difference is that I'm trying to teach the AI to respond sensibly to overcrowding, in addition to optimizing for species diversity.) Sorry about the lack of comments. I may add those in in r22232 ;)

User avatar
harpy eagle
Posts: 276
Joined: Sat Mar 10, 2018 3:25 am

Re: Strategic AI Mod

Postby harpy eagle » Tue Apr 24, 2018 7:32 am

Update (097f859):
  • Reworked planetary improvement selection to encourage the AI to build more factories. The AI no longer cares about the build time of improvements, I don't think it was helping. The AI no longer cares about max sustainable hammer production - if it has more production capacity than it can supply with minerals, it just tries extra hard to get more mines.
  • When determining it's desired mineral income, the AI only looks at planets that have at least one factory.
  • Overhauled ship construction desire, to accommodate some important bugfixes in vanilla. I've tried to strike a balance between building up naval power while also allowing for construction of colony ships/outposts/etc.
  • If the AI doesn't have enough transports to meet it's food import needs, it assigns a higher priority to civilian transport production.
  • The AI will no longer attempt to build ground units on planets that are not fully developed when revolt chance is 0.
  • Removed pop transfer code in favour of the vanilla version.

NOTE: this update may requires the beta test branch.

zolobolo
Posts: 910
Joined: Fri Nov 25, 2016 3:49 pm

Re: Strategic AI Mod

Postby zolobolo » Tue Apr 24, 2018 12:05 pm

harpy eagle wrote:Update (13edc0a): The AI will now move population between worlds if doing so would increase the population cap of the destination world and doing so would leave at least 1 pop of that species left on the source world.

Does this mean that you can trigger population related events as well?

Is it possible to have the AI issue a command to enslave/free and harmonize/deharmonize pops?
Something along the lines of:
WHEN Slave collar/Harmonization tech present (though I am not sure there is a tech for Tinkers - would be sensible though as then it could be reverse engineering like slave collars)
THEN IF moral<15 AND rebellion chance >0 THEN enslave/harmonize ELSE free/deharmonize

Or an even more simplified approach would be to activate enslavement and harmonization every time when available and never revert it. This is not that effective but might be much more simple and fun for the player to encounter

Enslavement could also affect Gremak build order as Marauder units become useful to have especially with the simplified logic

It would also have an effect to pop transport as unruly elements should not be placed on planets where they start a rebellion right off the bat and planets colonized by slaves would need a transport of suppressing pops/troops right away to keep the new estate

zolobolo
Posts: 910
Joined: Fri Nov 25, 2016 3:49 pm

Re: Strategic AI Mod

Postby zolobolo » Tue Apr 24, 2018 2:23 pm

Attachments
Prefered Improvement.png
Prefered Improvement.png (88.15 KiB) Viewed 746 times

zolobolo
Posts: 910
Joined: Fri Nov 25, 2016 3:49 pm

Re: Strategic AI Mod

Postby zolobolo » Tue Apr 24, 2018 2:33 pm

harpy eagle wrote:As for (2), what was happening was that the AI decided it wanted 5 scouts, but only had 3.

It looks like the second most desired ship was heavy cruisers, so it probably will return to building those once the scouts are done. While nothing here seems particularly amiss, I've gone and tweaked the scout desire anyways.

Seems to have worked: the Gremak AI now has 3 Scout Cruisers and started producing a Heavy Cruiser and 2 Destroyers at once without exceeding its metal income :)

It is also distributing pop units - this should give the AI economy quite a boost everywhere on the mid-long term

Do you know what the condition for producing Shipyards is? Might benefit from a bump up in weight for the top production worlds if metal reserves allows it (which is true in this case)

User avatar
harpy eagle
Posts: 276
Joined: Sat Mar 10, 2018 3:25 am

Re: Strategic AI Mod

Postby harpy eagle » Tue Apr 24, 2018 3:13 pm

zolobolo wrote:Seems to have worked: the Gremak AI now has 3 Scout Cruisers and started producing a Heavy Cruiser and 2 Destroyers at once without exceeding its metal income :)

It is also distributing pop units - this should give the AI economy quite a boost everywhere on the mid-long term

Do you know what the condition for producing Shipyards is? Might benefit from a bump up in weight for the top production worlds if metal reserves allows it (which is true in this case)

The AI only ever builds shipyards as part of building a ship that requires them.

But they do provide a discount to ship production costs, right? So it may be worth considering building them on their own. Though I'd need to figure out exactly when it makes sense to do so. For example, the AI probably shouldn't build them on worlds that are under threat of attack.

Speaking of which, the AI is pretty bad at defending it's key planets sometimes. It will send it's fleets off to guard some unimportant planet even though there are hostile ships just a few turns away. I've seen the AI lose their homeworlds this way, despite having a fleet large enough to fend off any invasions - I should probably keep a save the next time.

User avatar
harpy eagle
Posts: 276
Joined: Sat Mar 10, 2018 3:25 am

Re: Strategic AI Mod

Postby harpy eagle » Tue Apr 24, 2018 3:27 pm

zolobolo wrote:Improvement selection error

That's really weird. I'm not sure how that's possible. Gotta load up the save.
Last edited by harpy eagle on Tue Apr 24, 2018 3:32 pm, edited 1 time in total.


Return to “Modding”

Who is online

Users browsing this forum: No registered users and 2 guests