Difference between revisions of "User:Darth Fool"

From The Battle for Wesnoth Wiki
m
m
Line 1: Line 1:
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
+
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.  This is primarily meant as a way to organize my thoughts and reduce the time from when the code is complete to when the new AI is fully documented.  You have been warned.
release.
 
  
  
Line 15: Line 14:
  
 
  [order]#This tag specifies the beginning of an order description.   
 
  [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
 
   name = #the name of the order.  Acts to id units that are part of this order
 +
  id = #uniq ID of this order tag.  Used when executing summon commands.
 +
  execute = # yes(default) or no.  If yes will execute when encountered. 
 +
            # If no, only executed if explicitly called by an execute command.
 +
  memory = #In the various calculations, use the last seen locations of units that
 +
            # are now invisible if they were last seen within memory turns.   
 
   [fill]#command to attempt to fill the order with units that match the appropriate unit filter
 
   [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
 
     number = #command of how many units to fill that match the filter
Line 37: Line 40:
 
   [/command]
 
   [/command]
 
   [command]
 
   [command]
     type = break # stop executing this order.
+
     type = break # stop executing this order for this unit. 
 +
    #Should really have a filter otherwise makes all following commands never be executed.
 
   [/command]
 
   [/command]
 
   [command]
 
   [command]
Line 54: Line 58:
 
   [/command]
 
   [/command]
 
   [/order]
 
   [/order]
 +
 +
Note that orders with the same name can be used multiple times and will keep the same units between calls, but they should each have a unique id.

Revision as of 03:39, 18 May 2007

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. This is primarily meant as a way to organize my thoughts and reduce the time from when the code is complete to when the new AI is fully documented. You have been warned.



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.  
  name = #the name of the order.  Acts to id units that are part of this order
  id = #uniq ID of this order tag.  Used when executing summon commands.
  execute = # yes(default) or no.  If yes will execute when encountered.  
            # If no, only executed if explicitly called by an execute command.
  memory = #In the various calculations, use the last seen locations of units that 
           # are now invisible if they were last seen within memory turns.    
  [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 for this unit.  
    #Should really have a filter otherwise makes all following commands never be executed.
  [/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]

Note that orders with the same name can be used multiple times and will keep the same units between calls, but they should each have a unique id.