Page 1 of 1

How to get the AI to make air units and use nukes?

Posted: Sat May 14, 2022 1:39 am
by Sanguivorant
I have been trying this entire afternoon to get the AI to build air units, but it just won't.

The AI is really good at making a ton of land units like riflemen, fanatics, partisans, mech inf, and also good at making sea units like AEGIS cruisers, but I have never seen an AI make a single fighter.

I sometimes see the AI make one or two helicopters, but that's about it. Also, the AI will never use nukes, no matter how many they have. They do not build them either. If I edit in a few nukes for the AI, it will just sit there the whole game.

The AI from the Github source code is pretty effective at using fighters, I edited a fighter for an AI in the beginning of the game and watched it be used quite effectively to kill other AI.

So how can I make the AI heavily favour building air units? Thanks.

Re: How to get the AI to make air units and use nukes?

Posted: Sat May 14, 2022 3:51 am
by cazfi
I don't have an answer to you, except that the code is afraid of building fuel using or hitpoint losing units. But if you manage to do any improvements to the code, please submit them to https://osdn.net/projects/freeciv/ticket/

Re: How to get the AI to make air units and use nukes?

Posted: Sat May 14, 2022 1:16 pm
by Sanguivorant
cazfi wrote:I don't have an answer to you, except that the code is afraid of building fuel using or hitpoint losing units. But if you manage to do any improvements to the code, please submit them to https://osdn.net/projects/freeciv/ticket/
I'm honestly at a loss with where to start. Not even entirely sure how the program knows to read the AI script, or where the AI script is located after the game is compiled. I might have to experiment for a bit, but if anyone in the forum has an answer for making the AI heavily prefer air units, feel free to post here. Current problems with air:

-AI will not build air units, except for helicopters on some occasion.
-AI can only use fighter/type aircraft such as fighters or stealth fighters; they do not know how to use any bomber aircraft.
-AI does not build any missile units such as cruise missiles or nuclear missiles.

Who made the AI script, or who is actively developing the AI script? Is there a way for me to get a hold of them and ask questions?

Re: How to get the AI to make air units and use nukes?

Posted: Sat May 14, 2022 9:00 pm
by Ignatus
Sanguivorant wrote:I'm honestly at a loss with where to start. Not even entirely sure how the program knows to read the AI script, or where the AI script is located after the game is compiled. I might have to experiment for a bit, but if anyone in the forum has an answer for making the AI heavily prefer air units, feel free to post here. Current problems with air:

-AI will not build air units, except for helicopters on some occasion.
-AI can only use fighter/type aircraft such as fighters or stealth fighters; they do not know how to use any bomber aircraft.
-AI does not build any missile units such as cruise missiles or nuclear missiles.

Who made the AI script, or who is actively developing the AI script? Is there a way for me to get a hold of them and ask questions?
Well, AI is basically made by participants long out of the project, but the latest big changes in air unit handling are partially done by me. Yes, AI seems to not like building planes. Planes will be never built until AI player learns a tech with "Build_Airborne" flag. It builds helicopters but does not know how to use them, so it would better not... It should by design know a way to use bombers (fuel=2 units), but again, not that it likes building them. Also, AI does not know about the bombardment type attacks, and even if it knew, it has problems coordinating strikes that makes them less useful.

Re: How to get the AI to make air units and use nukes?

Posted: Sat May 14, 2022 9:52 pm
by Sanguivorant
Ignatus wrote: Well, AI is basically made by participants long out of the project, but the latest big changes in air unit handling are partially done by me. Yes, AI seems to not like building planes. Planes will be never built until AI player learns a tech with "Build_Airborne" flag. It builds helicopters but does not know how to use them, so it would better not... It should by design know a way to use bombers (fuel=2 units), but again, not that it likes building them. Also, AI does not know about the bombardment type attacks, and even if it knew, it has problems coordinating strikes that makes them less useful.
I'm assuming the Flight tech contains the "Build_Airborne" flag by default, or is that something that I would need to change and recompile? Which file is used to define these kinds of attributes, I'm assuming it's in the aimilitary.c file?

Re: How to get the AI to make air units and use nukes?

Posted: Sat May 14, 2022 10:30 pm
by Ignatus
Sanguivorant wrote:I'm assuming the Flight tech contains the "Build_Airborne" flag by default, or is that something that I would need to change and recompile? Which file is used to define these kinds of attributes, I'm assuming it's in the aimilitary.c file?
You don't need to recompile anything, the flag should be defined in (freeciv_data_dir)/(your_ruleset)/techs.ruleset.

But if you want to see hardcoded AI details, yes, go to aiunit.c, as well as daimilitary.c and aiair.c. I see, for example, that air attacker "want" is calculated with kill_desire() with wictim count always 1 while for simple units (land/naval) it's often number of units on tile, and this function favors multikill. Also, air units can't capture cities and can't fortify that put them in AI's eyes lower compared to land units that do it; and air units don't get e.g. score bonus for being able to attack from non-native as ships do since AI just can't see they don't need this bonus. Yes, that all needs hours of groking through and a good cleanup.

Re: How to get the AI to make air units and use nukes?

Posted: Sat May 14, 2022 10:47 pm
by Sanguivorant
You don't need to recompile anything, the flag should be defined in (freeciv_data_dir)/(your_ruleset)/techs.ruleset.

But if you want to see hardcoded AI details, yes, go to aiunit.c, as well as daimilitary.c and aiair.c. I see, for example, that air attacker "want" is calculated with kill_desire() with wictim count always 1 while for simple units (land/naval) it's often number of units on tile, and this function favors multikill. Also, air units can't capture cities and can't fortify that put them in AI's eyes lower compared to land units that do it; and air units don't get e.g. score bonus for being able to attack from non-native as ships do since AI just can't see they don't need this bonus. Yes, that all needs hours of groking through and a good cleanup.
I want to thank you so much for your help.

I have some background experience coding in C++, I guess what I can do is look at code and see if I can understand it good enough to make the AI understand the benefits of having air units, though honestly that might require a complete overhaul of the AI structure.

As you said, it would require a good cleanup.

Re: How to get the AI to make air units and use nukes?

Posted: Mon May 16, 2022 10:35 pm
by nef
Sanguivorant wrote: The AI is really good at making a ton of land units like riflemen, fanatics, partisans, mech inf, and also good at making sea units like AEGIS cruisers, but I have never seen an AI make a single fighter.
I have had ONE occasion using fc2.6.6 where a trireme of mine was sunk by an AI fighter. Didn`t see it of course (fc client has it`s own idea on what you see). As for air units in general -nothing else but I note that all are "field" units in my version of civ1, and the Ai paradigm of ICS (smallpox) and fixation on democracy may be one reason for aversion.