[BTS] Does the Ai delete units?

Inthegrave

Warlord
Joined
May 28, 2019
Messages
165
If the Ai had either a ineffective unit or a outdated one would the unit delete it?

I'm asking because I removed the class upgrades on all vehicles, ships and air units.
I thought it was unrealistic because normally vehicles are decommissioned
and scrapped once out of date, you can't magically transform a wooden boat into a steel battleship.
Also I wanted it to feel more rewarding building a vehicle.

Now since I did this, this means units don't go obsolete in the usual manner.
But I use ROM AND's ForceObsoleteTech flag for my civ4unitinfos to keep units
from showing up in the build queue in later eras.

What I'm worried is does the Ai know what to do with their older units?
Will they delete them once they become too weak or out of date?
I worry they might let their old units sit around causing them unnecessary financial strain.
 
Last edited:
There is certainly AI code for disbanding, chiefly I think in AI_doTurnUnitsPost and AI_doMilitary in CvPlayerAI.cpp. Here's a link to the RoM version of that file: SourceForge

AI_doMilitary only matters when the AI is already in "financial trouble", and I'm not sure how reliably the other function works.

There are also some scrap calls in CvUnitAI, mainly for units with a non-military role that is no longer needed (e.g. an exploring Workboat once it has explored all reachable tiles).
 
There is certainly AI code for disbanding, chiefly I think in AI_doTurnUnitsPost and AI_doMilitary in CvPlayerAI.cpp.

Alright so they have some code for it. But what about a very weak unit? Since I removed all vehicle upgrades the Ai might think a biplane in the transhuman era is "modern".
Aleast from your discovery's it seems the ai might not know what to do with it.

Here's a link to the RoM version of that file: SourceForge

Are these the source files for the ROM AND version found here?:http://anewdawn.sourceforge.net/
I'm asking because I know ROM has many different versions and I want to make sure it's compatible, this one I think is referred to as AND2 and was last
updated in the beginning of 2019.
 
[...]Since I removed all vehicle upgrades the Ai might think a biplane in the transhuman era is "modern".
Aleast from your discovery's it seems the ai might not know what to do with it.
Right, I don't see a check for combat strength or obsoletion tech in AI_doTurnUnitsPost. AI_doMilitary tries to disband cheap units before expensive ones, but that'll only help when the AI is already suffering from unit costs. It's conceivable that the mod has added code for deleting units in some other place. Would have to track down all calls to CvUnit::kill to rule that out.

You could always run a test on AI Auto Play. Looks like the keyboard shortcut is Ctrl+A in RoM/AND (source). I'm not sure that the unit expenses would hurt the AI much, but, if the AI keeps many of those outdated units around indefinitely, it'll look bad.
Are these the source files for the ROM AND version found here?:http://anewdawn.sourceforge.net/
I'm asking because I know ROM has many different versions and I want to make sure it's compatible, this one I think is referred to as AND2 and was last
updated in the beginning of 2019.
As far as I can tell, yes. Last revision on 20 Jan 2019. Though the CvPlayerAI.cpp in particular hasn't been changed since 27 May 2017. One can browse individual files online, but, for downloading the whole codebase, an SVN client might be needed as described on the homepage you've linked to. There's also the "download snapshot" button, but I don't know if that will work well for such a large repository.
 
You could always run a test on AI Auto Play. Looks like the keyboard shortcut is Ctrl+A in RoM/AND (source). I'm not sure that the unit expenses would hurt the AI much, but, if the AI keeps many of those outdated units around indefinitely, it'll look bad.

It's always been Ctrl+Shift+Z for me, trying Ctrl+A doesn't seem to do anything. But yeah I did end up doing a few tests and it seems the ai will keep a few old units
around into the transhuman era although for the most part it seems to keep up to date. But I suspect that the Ai might only be keeping up to date because it keeps
running into financial trouble.

I'm probably going to have to go back to the old class upgrade system. Pity because I never liked how one vehicle could transform into another one.

an SVN client might be needed as described on the homepage you've linked to.

So what this page describes here?:
http://anewdawn.sourceforge.net/pages/install/#developer-installation-svnenglish

Forgive me I'm still trying to wrap my head around SVNs and DLL modding.
 
Last edited:
It's always been Ctrl+Shift+Z for me, trying Ctrl+A doesn't seem to do anything. But yeah I did end up doing a few tests and it seems the ai will keep a few old units around into the transhuman era although for the most part it seems to keep up to date. But I suspect that the Ai might only be keeping up to date because it keeps running into financial trouble.
I see. So testing isn't really conclusive. :undecide:

Changing the AI code wouldn't be a huge task, but also not just a matter of adding a check for the obsoletion tech somewhere.
I'm probably going to have to go back to the old class upgrade system. Pity because I never liked how one vehicle could transform into another one.
I imagine that it's not only the vehicles that are being upgraded but also the personnel and infrastructure, so I'm not sure that vehicles really stand out. At least the (BtS) upgrade paths for Mounted units (e.g. Horse Archer to Knight, War Elephant to Cuirassier) also strain the imagination. Either way, it would be nice to have the option to give some units no upgrade, e.g. for Cavalry.
So what this page describes here?:
http://anewdawn.sourceforge.net/pages/install/#developer-installation-svnenglish
Forgive me I'm still trying to wrap my head around SVNs and DLL modding.
Yes. The URL given there for the repository is svn://svn.code.sf.net/p/anewdawn/code/Trunk and for browsing I'd use sf.net/p/anewdawn/code.
 
Yes. The URL given there for the repository is svn://svn.code.sf.net/p/anewdawn/code/Trunk and for browsing I'd use sf.net/p/anewdawn/code.

Thank you I suppose I need to open A New Dawn (VS 2008).sln with VS? I'm using Microsoft Visual Basic 2010 Express. When trying to open the file It says
that the file is not supported by this version of the application. Do I need to be using VS 2008 as the filename suggests?
 
Maybe if you put only A New Dawn (VS 2008).sln and A New Dawn (VS 2008).vcxproj in an otherwise empty folder? That works for me with VS2010 Express. As far as I can tell, the other project files are either for different IDEs or unnecessary because they get generated by Visual Studio anyway. Maybe those files are somehow getting in the way.
 
Maybe if you put only A New Dawn (VS 2008).sln and A New Dawn (VS 2008).vcxproj in an otherwise empty folder? That works for me with VS2010 Express. As far as I can tell, the other project files are either for different IDEs or unnecessary because they get generated by Visual Studio anyway. Maybe those files are somehow getting in the way.

Hmm still getting the same result opening "A New Dawn (VS 2008).sln" in a new folder. Is it because i'm using Microsoft Visual Basic 2010 Express?
I know there is 3 other versions of 2010 that can be installed I have the basic version.

I can post a image of the error message if need be.
 
I have version 10.0.40219.1 SP1Rel, also Express. The .sln says "Format Version 11.00" in the first line. If I change that to 13.0 with a text editor, I get the error: "... was created by a newer version ... cannot be opened." You could try changing it to 10.0 or 12.0. Or perhaps you really don't have quite the right program version. :confused:
 
Or perhaps you really don't have quite the right program version.

I'm using the version provided from here:
https://forums.civfanatics.com/threads/the-easiest-way-to-compile-a-new-dll.608137/
Also I'm using windows 8.1.

You could try changing it to 10.0 or 12.0.
When changing the version to 10.0, the program tries to convert it with a setup wizard. Something tells me that won't work. I didn't attempt it yet.

Here is my version information:



Here is the error I get when opening "A New Dawn (VS 2008).sln":

 
Aah, now I see it. :hammer2:
Is it because i'm using Microsoft Visual Basic 2010 Express?
I know there is 3 other versions of 2010 that can be installed I have the basic version.
Yes, that's the wrong version. That's for the Visual Basic programming language. Needs to be C++. The word "Basic" is so easy to miss; it's all over your screenshots, but I only noticed after downloading the ISO and starting the installer because I was curious what choices there are.
 
Top Bottom