#1520 closed enhancement (fixed)
Add technology support to AIs
Reported by: | historic_bruno | Owned by: | |
---|---|---|---|
Priority: | Should Have | Milestone: | Alpha 15 |
Component: | UI & Simulation | Keywords: | |
Cc: | Patch: |
Description
AIs currently ignore the existence of technologies. The following are changes needed at minimum to fully support techs:
- Modify the AI's entity template data in response to tech modifications (see #1358)
- Modify entity collections in response to tech modifications
- Pass list of researched and available techs through to the AIs
- Add some research plans to the AIs, starting with qBot
Attachments (1)
Change History (14)
comment:1 by , 12 years ago
by , 12 years ago
Attachment: | experimental-ai-techs-r12056.patch added |
---|
comment:2 by , 12 years ago
Attached partial patch for adding techs to AIs, split from work on #1358. I don't know if the approach is any good, but it's certainly not complete :)
follow-up: 4 comment:3 by , 12 years ago
Since I have a few connections on the issue... From what I gather, the AI should only ever receive the "after tech" template informations, which is now the situation after 12056(not sure I got this). I don't think the AI would care about the basic templates, it's, to me, needless complexity. In turn, entity collections and entity would automatically be up to date, because to the AI there would be no difference. Then there must be: A way for the AI to know which technology is available, its cost, where it can be researched (I'd say a list of any building that could research this, the AIs will then be in charge of building the proper one for civilization X), and most importantly what benefits it brings. Then the AI needs a way to know which technology it already has, and which it is currently researching (possibly the progression too). And a way to actually research a technology.
The AI scripts also need to take into account the fact that no longer can they build every building immediately. I'm not sure where to put this, I guess somewhere in "entity.js" in the common-api, as a check when given a "build" order, or rather as a standalone check so it can be used at different levels.
(this is mainly directed towards Quantumstate) As for implementing technologies in the scripts, I recommend using the same thing AOE developers did: separating the "Update" functions of econ/military for each phase. It allows for tighter control, more precise behavior, and less complexity overall (I think). Without, you'll probably have to invent a very clever dynamic system to know which technology to research, and to deal with phase techs, which may not be worth it.
comment:4 by , 12 years ago
Replying to wraitii:
Since I have a few connections on the issue... From what I gather, the AI should only ever receive the "after tech" template informations, which is now the situation after 12056(not sure I got this). I don't think the AI would care about the basic templates, it's, to me, needless complexity.
This isn't true as far as I know. Currently the AI manager has a single set of entity template data, which each AI shares. That data is never updated since it doesn't change. The data doesn't come from GuiInterface
(unlike some other simulation state) so r12056 shouldn't change anything.
There are a few issues. One as you said, the AI should always use the updated template data, which means updating the original shared template data (unless we redesign this somehow). Also the common-api Entity
class is initialized with an EntityTemplate
which it uses for most base stats, see entity.js.
So any Entity
or EntityTemplate
objects the AI stores can be possibly outdated after a tech is researched. Maybe all of that should be redesigned taking dynamic stats into account.
follow-up: 6 comment:5 by , 12 years ago
EntityTemplate should only ever call that shared set of template data, right? In this case, I see two solutions: you give each AI its set, and you update it accordingly, oy for each call to this set, you check for the AI's tech and you return up-to-date value. Entity should only ever be used to access data that can't be read from a template (in theory.I think the common api respects this convention mostly. ). In this case, the problem can probably be solved some other way.
comment:6 by , 12 years ago
Cc: | added |
---|
Replying to wraitii:
entityTemplate should only ever call that shared set of template data, right? In this case, I see two solutions: you give each AI its set, and you update it accordingly, oy for each call to this set, you check for the AI's tech and you return up-to-date value (probably easier to do in the short run, but probably slower for the AIs too).
Right, the shared data is to reduce memory usage of the AIs. We could give each AI their own copy, but it seems updating every possibly changed data of every template for every AI would be a waste. Perhaps the updater would be smart enough to know which areas to focus on (based on changes in researched techs between turns).
I think the most efficient method is on-the-fly stats calculation with some caching, as techs don't change constantly. The AIs won't need most of the stats, most of the time (I hope) :) Though I don't have any way to prove that's most efficient.
It comes down to whether tech modifications should be pulled in by the AI as needed or pushed into the AI regardless.
comment:7 by , 12 years ago
Using caching, it would work very well... Right now, I don't think AIs constantly call for templates, but as their complexity increase, I'd expect them to rely more and more on stats, so we should probably not cripple their ability to do so.
comment:8 by , 12 years ago
Okay, I took over this issue. Historic_bruno, I redid the thinking process independently yesterday and we agree on the method to use. I'm starting from your patch, fixed to use the correct tech modifications for each player.
comment:9 by , 12 years ago
Points 1, 2 and 3 should be done (though they might require cleaning up) in the API v3 from my RC Aegis/V3 API bot. Point 4 is not really done, though Aegis will go up phases.
I recommend PM-ing me if someone wants to build up on this and has questions.
comment:10 by , 11 years ago
Cc: | added |
---|
comment:11 by , 10 years ago
Cc: | removed |
---|---|
Milestone: | Backlog → Alpha 16 |
Resolution: | → fixed |
Status: | new → closed |
Fixed for over a year now. AIs need to improve how they research tech but the capacity is there. Closing this.
comment:12 by , 10 years ago
Milestone: | Alpha 16 → Alpha 15 |
---|
In 12056: