Commit graph

62 commits

Author SHA1 Message Date
Celtic Minstrel
17ea7fac6b Reorganize the AI source files a little
This also tries to make them include everything by full paths instead of relative paths.
2016-03-24 00:08:12 -04:00
Celtic Minstrel
c49fc8a72b Fix wesnoth.debug_ai()
(Also change some internal variable names)
2016-03-22 07:22:22 -07:00
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
e2cbe50781 Allow external Lua CAs to use [params] instead of {exec,eval}_parms 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
Celtic Minstrel
08b11139a1 Log useful error messages (and don't crash) when creating a goal with the wrong engine 2016-03-22 07:22:22 -07:00
Celtic Minstrel
bc711f5f43 Consolidate related files into subdirectories 2016-03-20 16:20:09 -04:00
Charles Dang
83ee4f6087 Convert most includes to src/-relative
This excludes includes that need backtrack path specifiers in order to resolve
name clashes.
2016-03-19 19:35:17 +11:00
Chris Beck
ba51524f6e update copyright to year 2016
using this shell script:

find src -type f -print0 | xargs -0 sed -i "s|Copyright (C) \([[:digit:]]*\)\([ ]*\)-\([ ]*\)2015|Copyright (C) \1\2-\32016|g"
2016-01-02 23:59:31 -05:00
Ignacio R. Morelle
57ae45387a New Year copyright update 2015-01-01 19:07:35 -03:00
Chris Beck
042b72a4b8 rename scripting/lua.?pp to game_lua_kernel.?pp 2014-11-09 18:45:14 -05:00
Chris Beck
97d5d14e27 fixup camel case names UnitPtr, UnitConstPtr
This commit created using sed, in directory src/:

$ find . -type f -exec sed -i 's/UnitPtr/unit_ptr/g' {} +
$ find . -type f -exec sed -i 's/UnitConstPtr/unit_const_ptr/g' {} +

and inspecting the results.
2014-06-29 11:55:48 -04:00
Chris Beck
9e7dc5ba00 unit_map, lua, team recall lists use reference counted UnitPtr
Defines a UnitPtr (boost::intrusive_ptr<unit>, after irc
discussion), which the engine will use to pass units between
different modules, and which it is planned that the animation
engine will also hold, to avoid segfaulting.

Unfortunately this commit could not really be made smaller, it is
necessary to change all of these things over at once, or specify
very complicated deletion policies for the units at the
boundaries of the modules.

The main intention of the commit is to get these three modules
using a reference counting system to hold units, even as they
are passed between the modules. Eventually the fake units and
other kinds of units will all also be held in such pointers, and
the unit_map::unit_pod object will be replaced itself with a
single smart pointer.

Finally the animations objects will hold weak pointers to units,
to fix the segfault issues.

This commit required us to change over the whiteboard, most of
the action_wml, and the AI modules, since these make use of the
recall list from the team class.

We also add the unit_ptr.hpp header file, to allow to forward
declare the UnitPtr object essentially, and it's const variation.

If we forward declare the intrusive_ptr functions, we can forward
declare the UnitPtr type and avoid including unit in a bunch of
places that we don't need to. (Good as that is a very heavy
include.)

The declaration is now in unit_ptr.hpp

Since we can't forward declare inheritance, the easiest way to
resolve linker problems is to not derive unit from the
reference_counted_object class and just include the intrusive_ptr
boilerplate as usual instead.
2014-06-15 14:57:47 -04:00
Ignacio R. Morelle
a4f47a63c7 New Year copyright update 2014-01-01 02:08:52 -03:00
mattsc
6c39832c86 Lua AI external CAs: change order of eval/exec parameters
The table with configuration parameters is needed much more frequently
than the persistent data variable, so it should come first.
2013-10-24 07:24:54 -07:00
mattsc
5a68773431 Lua AI external CAs: allow parameters for eval/exec functions
It is now possible to call the evaluation and execution functions with
sets of parameters.  These are transferred as strings containing
serialized Lua tables (without the {}), similar to how it is done for
"normal" CAs.
2013-10-23 20:46:30 -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
flix/Felix Bauer
f9a231f09d AI/lua: Command 'lua wesnoth.debug_ai(2).ai' gives now access to ai-table 2013-06-01 15:35:15 +03: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
Eric S. Raymond
043c4f9fd3 Remove $Id$ cookies. 2013-03-26 21:41:37 -04:00
Mark de Wever
43b71f2ff0 New year copyright update. 2013-01-01 09:22:03 +00:00
Mark de Wever
4c02c4daa5 Strip trailing whitespace. 2012-08-31 17:58:05 +00:00
Dmitry Kovalenko
51e818b43b LuaAI: wesnoth.debug_ai() slightly refactored,
...now provides access to the ai.* table, the Lua engine table and the
component tree
2012-08-14 07:26:58 +00:00
Mark de Wever
062fb91ba2 Strip trailing whitespace. 2012-06-30 20:28:23 +00:00
Dmitry Kovalenko
552b6b0c7e LuaAI: fixed bug #19782 and made the code more safe. 2012-06-21 11:49:40 +00: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
Dmitry Kovalenko
a72febe0e4 LuaAI: first draft of the external candidate action system,
...with on-the-fly file reloading, if you use the --debug-lua launch argument
2012-06-07 09:53:19 +00:00
Dmitry Kovalenko
57aa197583 LuaAI:
(1) Lua CA_wrapper slightly refactored, in preparation for adding CA
definitons using external files

(2) --debug_lua command line argument added. Unused at the moment, but
will be used for Lua debug mechanisms
2012-06-01 12:57:14 +00:00
Ignacio R. Morelle
b1105366d5 ai/composite: Use normal #include instead of system #include 2012-02-25 05:40:07 +00:00
Ignacio R. Morelle
6ca69b2df5 New year copyright update 2012-01-07 02:35:17 +00:00
Dmitry Kovalenko
2a9a663980 Lua backed goals now available(docs to be updated tomorrow)
//some minor fixes
2011-08-06 16:06:24 +00:00
Dmitry Kovalenko
8dc1551d30 Exposed the target list to Lua // minor fixes 2011-08-05 13:25:35 +00:00
Mark de Wever
e7123d786c Strip trailing whitespace. 2011-07-30 12:05:19 +00:00
Dmitry Kovalenko
a3acad0d70 It is possible now to store data in the Lua AI engine...
...and the data persists between save/load routines // Needs slight
refactoring, use at your own risk
2011-07-21 10:31:01 +00:00
Dmitry Kovalenko
a293e91db3 Completed cleanup functionality(kind of hacky, might need refactoring). Also done some minor fixes 2011-07-08 09:40:08 +00:00
Mark de Wever
9af56f9ac5 Strip trailing whitespace. 2011-07-07 19:16:19 +00:00
Dmitry Kovalenko
79a154e9c5 Sticky behaviours now mark themselves to_be_removed...
...when encounter that their bound unit is missing(dead or some other
reason). Also the RCA_Loop was extended to call a function that
removes all the CAs marked to_be_removed, but the functionality was
not implemented completely yet
2011-07-05 13:17:35 +00:00
Dmitry Kovalenko
bab732a43e Sticky candidate actions are constructed if sticky=yes specified
(Lua engine only). Also added missing unit coordinate parameters to
the config
2011-07-04 11:19:56 +00:00
Mark de Wever
524c00b847 Strip trailing whitespace. 2011-06-30 20:24:58 +00:00
Mark de Wever
f37d49fcf8 Properly name a private variable.
Private variables should have a trailing underscore.
2011-06-30 20:24:51 +00:00
Mark de Wever
f1e3dafc8e Initialize all members. 2011-06-30 20:24:48 +00:00
Dmitry Kovalenko
8d65c3b7f7 Added functionality to the [add_ai_behavior] tag.
Not fully working at the moment, but is usable. The usage syntax will
most probably remain, but the internals will be modified.
2011-06-30 14:14:46 +00:00
Dmitry Kovalenko
849a8ab765 Added a sticky_ field to lua CA.
Sticky CAs will now disable themselves after execution
2011-06-26 19:36:08 +00:00
Mark de Wever
d9a28eccae Strip trailing whitespace. 2011-06-18 08:27:10 +00:00
Dmitry Kovalenko
b2ce483b71 Lua aspect foundation 2011-06-01 13:47:33 +00:00
Mark de Wever
ecbabea838 New year copyright update. 2011-01-01 15:57:50 +00:00
Guillaume Melquiond
eeb047de55 Fixed file headers so that they match the content of the COPYING file. 2010-09-01 21:12:38 +00:00
Iurii Chernyi
c62753c025 fix serialization of lua ai engine to config 2010-07-27 20:32:33 +00:00
Mark de Wever
a99c78e0d8 Update doxygen comment.
The filename after the @file comment is optional (spotted by alink).
2010-07-26 21:32:18 +00:00