Preliminary Evaluation: AI Development Questions

Discussion of all aspects of the game engine, including development of new and existing features.

Moderator: Forum Moderators

Post Reply
KaptinKurk
Posts: 6
Joined: April 13th, 2009, 4:56 am

Preliminary Evaluation: AI Development Questions

Post by KaptinKurk »

Hello, I would like to know (before I actually start any work) the following:

1) Are all the AI scripts and such in Lua? (Based on my basic peerings the answer is yes.)
2) When are AI scripts executed? Are they only executed during the turn of a computer, or are they always able to execute even during another player's turn?
3) Are all of the scripts run in separate global domains or can multiple AIs using the same script share the same globals, while having player local variables?

Thanks.
User avatar
iceiceice
Posts: 1056
Joined: August 23rd, 2013, 2:10 am

Re: Preliminary Evaluation: AI Development Questions

Post by iceiceice »

1.) Not exactly. The current system we have is called "Composite AI". It means that the C++ engine allows AI components to be written in different languages and plugged together interchangeably.
- Stage is the most general AI concept, its just a routine that "does something".
- Most AIs focus on a special kind of stage called a "Candidate Action" evaluation stage. This stage is written in C++ and built into the engine.
- A candidate action is something that can evaluate the gamestate and give a score, and also can be "executed" somehow. The candidate action evaluation stage collects many candidate actions, repeatedly collects their scores, picks the best one and runs it.
- Candidate actions can be written in C++ or lua. lua is advantageous because you won't have to a wait a year or so for the next release before others can get your AI. You can have some candidate actions in lua and some in C++, for instance you can retain all the candidate actions of the default AI if you want. (Which is C++).
- Some other minor AI components include goals, facets, aspects... you'll have to read about these on the wiki. Generally these are also agnostic as to what language they are written in.

The most significant recent development is MicroAIs, which allow for one or a few units of a side to be controlled by a completely different algorithm, written in lua. This is extremely useful for getting good behavior in campaigns especially, if you need some units to behave like NPCs with a certain objective, or as guardian units in some fixed location etc.

2.) They are only executed during the turn of the computer.

3.) The AI are not run in separate global domains. There is one shared lua domain where all of the ai and also any scripts related to the scenario are run together. AI is not restricted not to "cheat", it can invoke arbitrary engine functions and change the gamestate arbitrarily. For some mods or alternative game modes this might come in handy. Anyways I'm pretty sure if you wanted multiple different AIs to synchonize / communicate using lua variables it would not be difficult.
KaptinKurk
Posts: 6
Joined: April 13th, 2009, 4:56 am

Re: Preliminary Evaluation: AI Development Questions

Post by KaptinKurk »

Thanks for the response, this should be helpful.
Post Reply