Difference between revisions of "Micro AIs"

From The Battle for Wesnoth Wiki
(The [micro_ai] Tag)
m
Line 1: Line 1:
 
'''''Important: This is a pre-release wiki page.  The functionality described below has not actually been released yet.'''''
 
'''''Important: This is a pre-release wiki page.  The functionality described below has not actually been released yet.'''''
 +
 +
  
 
The add-on ''AI Modification Demos'' contains a number of so-called Micro AIs (well, currently there's one, but the goal is to add more).  Mirco AIs add specific functionalities to a side's AI and can be added to a scenario easily using only a few lines of WML code.  Adding (or deleting) a Micro AI is done via the [micro_ai] tag, which also lets the campaign designer configure the AI behavior to the specific need of the scenario.
 
The add-on ''AI Modification Demos'' contains a number of so-called Micro AIs (well, currently there's one, but the goal is to add more).  Mirco AIs add specific functionalities to a side's AI and can be added to a scenario easily using only a few lines of WML code.  Adding (or deleting) a Micro AI is done via the [micro_ai] tag, which also lets the campaign designer configure the AI behavior to the specific need of the scenario.
Line 7: Line 9:
 
== Setting up a Micro AI ==
 
== Setting up a Micro AI ==
  
After installing the ''AI Modification Demos'' add-on, there are currently (for Wesnoth 1.10) 3 steps required to set up a Micro AI:
+
After installing the ''AI Modification Demos'' add-on, there are currently (for Wesnoth 1.10) three steps required to set up a Micro AI:
  
 
==== 1. Making the Micro AIs and [micro_ai] tag available in your add-on ====
 
==== 1. Making the Micro AIs and [micro_ai] tag available in your add-on ====

Revision as of 02:06, 3 September 2012

Important: This is a pre-release wiki page. The functionality described below has not actually been released yet.


The add-on AI Modification Demos contains a number of so-called Micro AIs (well, currently there's one, but the goal is to add more). Mirco AIs add specific functionalities to a side's AI and can be added to a scenario easily using only a few lines of WML code. Adding (or deleting) a Micro AI is done via the [micro_ai] tag, which also lets the campaign designer configure the AI behavior to the specific need of the scenario.

Note that the current Micro AIs are written for Wesnoth 1.10 in order to maximize the number of people that can give feedback on the AI behaviors. They should work in Wesnoth 1.11 as well (please report if you find that they don't), but they don't make use of the new features of the development version (yet).

Setting up a Micro AI

After installing the AI Modification Demos add-on, there are currently (for Wesnoth 1.10) three steps required to set up a Micro AI:

1. Making the Micro AIs and [micro_ai] tag available in your add-on

The following line needs to be added to your _main.cfg file, inside the #ifdef for your campaign:

{~add-ons/AI-demos/micro_ais/activate_micro_ais.cfg}

This loads the required AI files and sets up the [micro_ai] tag.

Note: If the Micro AIs were ever mainlined (in BfW 1.16 or so), this would not be needed any more, of course.

2. Setting up the Lua AI engine

Add the following line into the side definition (inside the [side] tag) of the side that should use the Micro AI:

    {MICRO_AI_ENGINE}

This does not yet activate any Micro AIs, but in Wesnoth 1.10 it is necessary to define the Lua AI engine inside the side definition, thus the need for this line. This requirement will go away for Wesnoth 1.11 making this step unnecessary. Note, however, that the current version of the add-on does not make use of this yet so as to be compatible with Wesnoth 1.10, so this line is currently required even if you are using Wesnoth 1.11.

3. Activating and configuring the Micro AI

Micro AIs are activated, deleted and configured using the [micro_ai] tag. This tag needs to be placed in ActionWML, that is, in an event, a menu option or the like. As an example, the following code activates the healer_support Micro AI in its default configuration for Side 2 from the beginning of the scenario:

    [event]
        name=prestart

        # Configure the healer support micro AI
        [micro_ai]
            side=2
            ai_type=healer_support
            action=add
        [/micro_ai]
    [/event]

For the full syntax of the [micro_ai] tag and the available Micro AIs, see the next sections.

The [micro_ai] Tag

The [micro_ai] tag activates, deletes and configures the Micro AIs for use in a scenario. It needs to be placed in ActionWML and must contain the following three required keys:

  • action (string): The action to take concerning the Micro AI. The following values are allowed:
    • add: Add a Micro AI to a side.
    • change: Change the configuration of an existing Micro AI. Note that this does not only change the specific parameters provided in the tag, but it replaces the entire existing Micro AI by a new version with the new (and only the new) configuration. It is therefore equivalent to using first the add and then the delete action.
    • delete: Delete an existing Micro AI from a side.
  • side: The side for which the Micro AI is to be added, changed or deleted
  • ai_type: The type of Micro AI to be added, changed or deleted. See the following sections for allowed values.

If no other keys are given, the Micro AI is set up in its default configuration when using the add and change actions. Additional keys allowed for each Micro AI are listed below. Note that the add and change actions ignore all keys that do not apply to the respective Micro AI type, and that the delete action ignores all keys other than the three required ones listed above.



Important: This is a pre-release wiki page. The functionality described above has not actually been released yet.