Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce AI production considerations #16633

Closed
wants to merge 2 commits into from

Conversation

pchote
Copy link
Member

@pchote pchote commented Jun 2, 2019

This PR extracts the metadata that the AI uses to decide what to build into its own trait, and generalizes the capabilities to be much more useful. The new BotProductionConsideration traits can be combined to reduce duplication, and can be toggled using conditions to modify the AI build priorities at runtime.

The main usecase for this is to let us define production overrides for the different difficulty levels (e.g. capping harvesters to 3 for Easy AI) without having to duplicate the entire module. I've implemented priority levels and the ability to toggle considerations using conditions which means that these overrides can be changed at runtime, opening up possibilities such as tech transitions and in the future replacing the hardcoded priority overrides. I've implemented an example of this in TD, with the AI only building helipads once they have a comm center, as it is useless to them earlier.

In the future I expect BotProductionConsideration can be superseded by more specialized traits defining team types for units, and build orders for buildings.

Prerequisite for #16126 (which I still believe is important for the next release)
Fixes #8029

I've set up TD reasonably well in the new system, but i'm at a complete loss at how to handle RA and D2K - opening as a draft to get some feedback and ideas on how to proceed.

The production percentages for these mods are just completely bogus with arbitrary numbers that are nowhere close to adding up to 100%. This partially explains why the AI production has always been wonky - in practice it is driven by priority overrides and limit caps, and otherwise basically random.

Consider the unit percentages: if we ignore the issue where they are completely ignored unless there are more than 12 idle units in the base (which is rare), then the percentages are still likely to be ignored. Many of the units define percentages in the 25-60% range, which will never be achievable. These units will therefore always pass the test to be built if they are picked by the random shuffle. Buildings have the opposite issue, with most structures requesting a 1% fraction, meaning that the AI wants to build approximately 0 of everything, which is rounded up to 1.

Migrating the numbers as they are doesn't make much sense and will probably regress behaviour - I have fixed several bugs that caused the limits and time delays to be ignored in some cases, and the unit percentages to be ignored almost all of the time.

I think the best option forward will be to get rid of the rush/normal/turtle/naval AIs here, and implement new production considerations from scratch that make some degree of sense. We can then have variants that e.g. build twice as many infantry/vehicles/air/defenses, and expose them either explicitly as "<X> AI"'s, or scope creep towards #16126 by going straight to a single "Normal AI" with the variants as random choices.

@GraionDilach
Copy link
Contributor

GraionDilach commented Jun 2, 2019

Keep in mind that the AI infantry compositions need to add up to 100% in RA atleast due to #11797.

namespace OpenRA.Mods.Common.Traits
{
[Desc("Controls AI production.")]
public class BotProductionConsiderationInfo : ConditionalTraitInfo
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BotProductionComposition is probably a better name for this.

@pchote
Copy link
Member Author

pchote commented Jun 2, 2019

If I can fix this to not noticeably regress the AI in each mod it would be best to merge with the bogus legacy definitions and then aim to implement a new AI skeleton in a followup.

I have created #16634 to plan this.

@reaperrr
Copy link
Contributor

reaperrr commented Jun 3, 2019

with the variants as random choices.

Why random?

@pchote
Copy link
Member Author

pchote commented Jun 3, 2019

See #16126

Copy link
Member

@abcdefg30 abcdefg30 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AI in TD seems to work quite well already with silos disabled.

nuk2: 10
proc: 20
Limit: 4
silo: 10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be removed (or effectively limited) as discussed on IRC.

Priority: 3
Actors:
hpad:
Limit: 2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No new line at the end of the file.

@ghost
Copy link

ghost commented Nov 2, 2019

It's not working with classic production queues.

@ghost
Copy link

ghost commented Nov 2, 2019

It's working after defining BuildingQueues and DefenseQueues for the BaseBuilderBotModule, Queues for BotProductionConsideration and adding powr to its Actors list. Took me too long to realize that building power plants is otherwise not a valid consideration...

So my issue was completely unrelated to ClassicProductionQueue.

@pchote
Copy link
Member Author

pchote commented Feb 27, 2020

I'm hoping to resurrect this for Next + 1, so adding to the milestone.

@KOYK
Copy link
Contributor

KOYK commented Apr 13, 2020

I am kinda confused reading all the file changes, so I will just ask.
Are we still going to be able to set the AI to build a pre set number of buildings or units if we want to?
Like I want it to build lets say EXACTLY 10 medium tanks and 3 apcs or 5 barracks and 1 ref, like we could before?

@pchote pchote added this to Base management improvements in Improve the AI May 5, 2020
- Consideration metrics split out to a BotProductionConsideration trait
- Unit composition fractions, build limits, and delays are now actually used
- AI will now build ONLY items specified in considerations
- Add structures that were not listed
- Remove duplicate definitions
- Require HQ before building HPAD in TD
@@ -267,15 +189,20 @@ Player:
ConstructionYardTypes: construction_yard
IgnoredEnemyTargetTypes: Creep
UnitBuilderBotModule@vidious:
=======
BotProductionConsideration@units-vidious:
>>>>>>> c91beaba0b... Overhaul bot production logic.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have rebase conflicts in here...

@pchote pchote modified the milestones: Next+1, Future Aug 15, 2020
@pchote
Copy link
Member Author

pchote commented Aug 15, 2020

Too many other things are happening right now to even pretend that we can come back to this soon. Moving to the Future milestone 😢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Improve the AI
  
Base management improvements
Development

Successfully merging this pull request may close these issues.

TD: AI should not build helipad when tech level = low
6 participants