Commit graph

7 commits

Author SHA1 Message Date
Celtic Minstrel
1d7c1c74f6 Improve backwards compatibility for Lua AI
This changes the following:
- Fixes the experimental AI, without changing any of its code except for that in the [engine] tag
- Returns a dummy self from the dummy Lua engine, so that external CAs are more easily switched to using [params]
- Changes the order in which parameters are passed to AI component code. The order is now:
        state/self,    params,    data
2016-03-22 07:22:22 -07:00
Celtic Minstrel
f8f5557eb0 Huge refactor of Lua AI engine
This commit potentially breaks any Lua AI customization, except for external Lua candidate actions.
In practice, though, Lua aspects and goals will probably continue to work for the most part.

- The ai table now has a read_only attribute.
  If true, functions that change the game state will be missing from the table.
  The read_only attribute is false in CA execution and in stages.
  It is true everywhere else.
- Every Lua AI component now supports a [args] subtag.
  The contents of this tag are passed as parameters to the component code.
  This data is immutable; components cannot alter its contents.
  (External Lua candidate actions do not receive this data.)
- Accessing the persistent engine data is now supported in all Lua components.

When calling a Lua component, the Lua engine now passes two parameters:
1. The contents of the [args] tag in the specific component.
2. The contents of the [data] tag in the Lua [engine].

The return value of the [engine] code, if any, is stored for later used.
It will be passed as the third parameter to any other Lua component.
This data can be changed, but will not be saved.
The default engine does not return any such data.
2016-03-22 07:22:22 -07:00
mattsc
8689543d9a Lua dummy engine: do not load debug_ai functions
Besides them being unnecessary, a warning message is otherwise also
displayed when external CAs are used and the game is not in debug mode.
2013-10-30 18:23:48 -07:00
mattsc
d5b994c0bb Lua AI: make persistent data variable work with external CAs
It was previously being set correctly by the engine, but was not
accessible from the Lua AI.
2013-10-23 18:39:26 -07:00
mattsc
78f753e4dc Revert "LuaAI: (1) persistent storage mechanism now available and working properly (2) old/incomplete mechanism not removed, subject to future deprecation"
This reverts commit 754f2c2b3d.
2013-05-13 13:15:22 -07:00
Dmitry K
754f2c2b3d LuaAI: (1) persistent storage mechanism now available and working properly (2) old/incomplete mechanism not removed, subject to future deprecation 2013-05-12 01:12:45 +03:00
Dmitry Kovalenko
b207a1b1ca LuaAI: the need to define an engine is now deprecated.
All CAs can be store in external .lua files. If the scenario config
lacks an [engine] tag for the Lua AI engine, but still tries to use CA
with engine=lua, a dummy engine will be automatically generated,
providing the needed functionality
2012-06-12 12:36:06 +00:00