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

From The Battle for Wesnoth Wiki
< GCI
m (Notes (23rd November))
(Notes (24th November))
Line 134: Line 134:
 
= Notes (24th November) =  
 
= Notes (24th November) =  
 
convert {NO_SCOUTS} to {AI_NO_SCOUTS}
 
convert {NO_SCOUTS} to {AI_NO_SCOUTS}
 +
= Notes (25th November) =
 +
{ai/aliases/stable_singleplayer.cfg} should be given inside [side] tag, inside each [side] tag where there's at least one [ai] tag.
 +
 +
please test your changes by loading every and each scenario from wesnoth to see if it loads without errors (use debug mode ':n' command to switch levels)

Revision as of 13:38, 24 November 2010

Use wesnoth 1.9.2 or work on trunk version.

You can download 1.9.2 from here: http://wiki.wesnoth.org/Download#Development_.281.9_branch.29


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

aggression

attack_depth

[avoid]

caution

grouping

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

Notes (23rd November)

everything should be converted. if it's unclear how to convert something, ask.

for attack_depth, you can convert it in the same way as aggression or, in the specific case '3 for easy, 4 for medium, 5 for hard', use {AI_SCALE_ATTACK_DEPTH_BY_DIFFICULTY} macro

ai goal syntax is at http://wiki.wesnoth.org/Customizing_AI_in_Wesnoth_1.8#AI_goals_.28_via_.5Bgoal.5D_tags_.29

to test the changes, you don't have to recompile - hitting F5 from main menu or restarting should be enough to refresh the cache and pick up new changes to WML code.

you can use :inspect - it allows you to see the ai configuration and you can compare the results of your changes vs the results of the 'upgrade' procedure written in c++ - by using :inspect two times, with and without your changes

Also, you're welcome to show incomplete results for review (link to these in google's task tracker)

If something varies by difficulty, or uses QUANTITY macro, e.g. {QUANTITY aggression 0.55 0.75 0.85} convert it using the ON_DIFFICULTY macro {AI_SIMPLE_ALWAYS_ASPECT aggression {ON_DIFFICULTY 0.55 0.75 0.85} }

Notes (24th November)

convert {NO_SCOUTS} to {AI_NO_SCOUTS}

Notes (25th November)

{ai/aliases/stable_singleplayer.cfg} should be given inside [side] tag, inside each [side] tag where there's at least one [ai] tag.

please test your changes by loading every and each scenario from wesnoth to see if it loads without errors (use debug mode ':n' command to switch levels)