Difference between revisions of "GCI/Port AI WML configuration to new style syntax"

From The Battle for Wesnoth Wiki
< GCI
(list of aspects which are converted that way)
Line 109: Line 109:
 
[target]\[protect_..] tags are converted to [goal] tags, see the new-style docs for details.
 
[target]\[protect_..] tags are converted to [goal] tags, see the new-style docs for details.
  
for other AI parameters, figure it out or ask Crab_ on the wiki.
+
for other AI parameters, figure it out or ask Crab_ on #wesnoth-dev on IRC at freenode

Revision as of 00:21, 23 November 2010

Use wesnoth 1.9 or work on trunk version.

Wesnoth uses a custom markup language called WML, which can be edited by hand (it's similar to xml)

AI configuration can be written using WML.

In 2009, a new style syntax for writing AI configurations in Wesnoth was created.

New syntax is described on http://wiki.wesnoth.org/Customizing_AI_in_Wesnoth_1.8

Old syntax is described on http://wiki.wesnoth.org/AiWML

We need to convert existing AI syntax to new style.

The preferred way to do it is to teach wesnoth's custom WML conversion tool, wmllint, (written in python) to do it, or to write a helper script to do it. Or it can be done by hand. In any case, human review is required, to see that everything is ok.

As an example of the conversion process, you can use the first scenario of Legend of Wesmere campaign:

before, it contained:

[ai]
   village_value=0
   leader_value=0
   protect_leader=0
   [avoid]
       x=1-30,1-30,1-3,7-30
       y=1-13,17-30,1-30,1-30
   [/avoid]
[/ai]

after:

{ai/aliases/stable_singleplayer.cfg}
[ai]
   {AI_SIMPLE_ALWAYS_ASPECT village_value 0}
   {AI_SIMPLE_ALWAYS_ASPECT leader_value 0}
   {AI_SIMPLE_ALWAYS_ASPECT_VALUE avoid (
       x=1-30,1-30,1-3,7-30
       y=1-13,17-30,1-30,1-30
   )}
[/ai]

Or, if we had separate config for 'night' time of day ( time_of_day=dusk,first_watch,second_watch)

before:

       [ai]
           recruitment_pattern=scout,fighter,fighter,archer,mixed fighter
       [/ai]
       [ai]
           time_of_day=dusk,first_watch,second_watch
           aggression=0.75
           caution=0.0
           grouping=offensive
       [/ai]

after:

 {ai/aliases/stable_singleplayer.cfg}
 [ai]
    {AI_SIMPLE_NIGHT_ASPECT aggression 0.75}
    {AI_SIMPLE_NIGHT_ASPECT caution 0}
    {AI_SIMPLE_NIGHT_ASPECT grouping offensive}
    {AI_SIMPLE_ALWAYS_ASPECT recruitment_pattern "scout,fighter,fighter,archer,mixed fighter"}
  [/ai]

you might need to ask questions about how a particular tag should be converted, ask Crab_ on #wesnoth-dev on freenode.

Conversion procedure

In general, we need to add {ai/aliases/stable_singleplayer.cfg} outside the ai tag. then, for each ai tag, we need to look if it's 'for all times or day' or for particular time of day. then, if it's an aspect, just use the appropriate form of

{AI_SIMPLE_NIGHT_ASPECT aspect_name aspect_value}
{AI_SIMPLE_DAY_ASPECT aspect_name aspect_value}
{AI_SIMPLE_ALWAYS_ASPECT aspect_name aspect_value}

list of aspects which are converted that way

[avoid]

caution

groupin

leader_aggression

leader_goal

leader_value

number_of_possible_recruits_to_force_recruit

passive_leader

passive_leader_shares_keep

recruitment_ignore_bad_combat

recruitment_ignore_bad_movement

recruitment_pattern

scout_village_targeting

simple_targeting

support_villages

village_value

villages_per_scout

[target]\[protect_..] tags are converted to [goal] tags, see the new-style docs for details.

for other AI parameters, figure it out or ask Crab_ on #wesnoth-dev on IRC at freenode