LuaAI

From The Battle for Wesnoth Wiki
Revision as of 16:07, 23 November 2009 by Crab (talk | contribs) (New page: Good lua support for Wesnoth's AI would be cool. Adding such support is not a rocket science - just several well-defined steps. # expose game state (readonly_context) to lua code #expose ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Good lua support for Wesnoth's AI would be cool. Adding such support is not a rocket science - just several well-defined steps.

  1. expose game state (readonly_context) to lua code
  2. expose action handlers ('move,attack,recruit,recall,stop' actions from readwrite_context) to lua code
  3. add a src/ai/composite/engine_lua.?pp which will take config snippets and return c++ objects which will act as wrappers to lua-based candidate actions/stages/aspects
  4. (optional) modify aspects code to make translation from/to lua objects less expensive
  5. (optional) somehow prohibit modification of game state via lua handlers (prohibit calling stuff such as wesnoth.fire() from AIs)

most of the work is a proper (1).

(4) and (5) are optional

(2) is very simple - just call a c++ function when lua function is called, translating the arguments. 'traslation via config' is already done by silene (see how wesnoth.fire works)

(3) is just some wrapper stuff - it's enough to do it for stages and candidate actions

in (1), for a base ai, it's needed to access the 1.1) our side number 1.2) game map info, 1.3) team info, 1.4) units info 1.5) scenario info such as income and time of day

future GSoCers, take notes !