User:Darth Fool

From The Battle for Wesnoth Wiki
Revision as of 03:26, 18 May 2007 by Darth Fool (talk | contribs)

This page is intended as a development page for the documentation of the new AI that I am working on. When the AI is officially released, the information will be migrated to the official wml reference pages. Some of this is partially implemented, some of it has not yet been implemented, and some of these are planned changes to something that is already implemented, and all of it is subject to change in the code without notification. So, in short, don't start using this in your scenarios and expect it to work just yet, or even to still be the same by the time of the official release.



The Grand Idea Ok, so what is this AI supposed to accomplish anyways. Well, it has many goals, but most of them can be wrapped up in the following statement: The AI should be sufficiently flexible to be able to specify parameters so that it can win Heir To The Throne on easy without cheating. That means, no knowing where things are before they are discovered (scepter of fire), no knowing where hidden or fogged units are, etc... Along the way, we should end up with an AI that makes it quite possible to create much more interesting AI behaviour in campaigns. so, how to accomplish this?

Orders

The basic scheme begins with a simple concept. The AI WML will be able to specify the order in which various objectives are accomplished, and by what units those orders are filled. Consider that currently, the AI pursues its goals in a very specific order (combat, village capture, healing, retreat, recruit...)

So, the first order of business is to enable the abilty to specify the order in which commands are executed. As a further refinement, we allow the order to restrict what type of units the order applies to. Inside the order are a series of commands that are executed. Units that fill that order remember which order they are following (via the ai_special tag in the unit) until they are reassigned. Units that have no ai_special are part of the "default" orders. Initially, any [fill] commands are executed within the order. After this, units are sorted according to any [sort] commands Then, for each unit in order the remaining commands are executed by that unit before the next unit executes the commands.

[order]#This tag specifies the beginning of an order description.

 id = #uniq ID of this order.  Used when executing summon commands
 name = #the name of the order.  Acts to id units that are part of this order
 [fill]#command to attempt to fill the order with units that match the appropriate unit filter
   number = #command of how many units to fill that match the filter
   [filter]#standard unit filter.[/filter]
   sort = #evaluation of how to choose which unit to accept first.  Higher value chosen first.
 [/fill]
 [sort] 
   [filter]#standard unit filter.
   [/filter]
   sort = #evaluation of how to choose which unit to accept first.  Higher value chosen first.
 [/sort]   
 [command]#generic tags for all commands
   [filter]#standard unit filter.  limits which units will execute this command.
   [/filter]
   type = #type of command to execute.  command specific WML tags below
 [/command]#move command
   type = moveto # move to target.
 [command]
   type = set_order # change the unit to be a part of a different order
 [/command]
 [command]
   type = break # stop executing this order.
 [/command]
 [command]
   type = attack # execute an attack.  Does not move the unit! 
 [/command]
 [command]
   type = recruit # recruit units.  Does not move the unit!
 [/command]
 [command]
   type = execute # execute the following order before continuing.
   id = #id of order to execute
 [/command]
 [command]
   type = summon # summon units to give current unit a boost before combat.  
   #possibly will be eliminated in favor of the execute command.
 [/command]

[/order]