Difference between revisions of "Wesnoth AI"

From The Battle for Wesnoth Wiki
m (A Very Brief History of Wesnoth AIs)
(AIs Available to Scenario and Map Designers: updated with current status in 1.15.3+dev)
 
(23 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{| class="wikitable" style="text-align: center;"
+
==Introduction to the Wesnoth AIs==
|'''This page is currently under construction (Feb 2016)'''
 
|}
 
  
 +
Wesnoth provides an artificial intelligence (AI) which is active by default for all computer-controlled sides, as well as several optional AIs.  These AIs are highly configurable and can be included and/or customized by scenario and map creators using simple WML code.  For AI developers, it is also possible to replace parts or all of the default AI with custom code.
  
==Introduction to the Wesnoth AIs==
+
This page provides a brief summary of the available AIs and of the methods, tools and resources available for using and modifying them.  Links are provided to detailed documentation on each of the topics.  For reference, we also provide a brief timeline describing some of the main development milestones of the Wesnoth AIs.
 +
 
 +
== Available AIs ==
  
Wesnoth provides a general artificial intelligence (AI) which is active by default, as well as several more specialized optional AIsThese AIs are highly configurable and can be included and/or customized by scenario and map creators using simple WML.  For AI developers, it is also possible to replace parts or all of the default AI with custom code.
+
This section briefly lists the different AIs available in Wesnoth.  Click on the links provided here and in the resources section below for detailed descriptions of the AIs and for instructions for using and customizing them.
  
This page provides a brief summary of the available AIs and of the methods, tools and resources available for using and modifying them.  Links are provided to more detailed pages on each of the topics.
+
=== AIs Available to Scenario and Map Designers ===
  
 +
Wesnoth comes with several built-in AIs from which scenario and map designers can choose:
  
==Available AIs==
+
* '''[[RCA_AI|Default (RCA) AI]]''': If no special instructions are given, this AI is used automatically for all computer-controlled sides with no setup needed.  It can be customized in many different ways.
 +
* The '''[[Experimental AI]]''' adds additional features to the RCA AI.  {{DevFeature1.15|3}} Several of the actions of the Experimental AI have been merged into the default AI.
 +
* '''[[Micro AIs]]''' add specialized behavior to Wesnoth that cannot be achieved with the default AI.  There is a large number of available Micro AIs and they can be set up using just a few lines of simple WML code.
 +
* '''[[Creating Custom AIs|Custom AIs]]''':  In addition to these AIs, Wesnoth provides a large variety of options for writing your own AI code.
  
Wesnoth comes with several built-in AIs:
+
=== AIs Available in the Multiplayer Setup Menu ===
  
* '''Default (RCA) AI:''' If no special instructions are given, this AI is used automatically for all computer-controlled sides with no setup needed.  In addition, it can be configured, modified and partly or fully replaced by custom AIs in a variety of ways.  For details see:
+
Several AIs are available to be chosen for computer players in the multiplayer setup menu:
** [[RCA_AI]]: More details on the fundamentals, functionality and components of the default AI
 
** [[AiWML]]: Description of WML methods and parameters for modifying the default AI's behavior
 
  
* The '''Experimental AI''' adds additional features to the RCA AI and can be added to both single-player scenarios and multi-player gamesIt is still under development (thus its name) and might change from release to release.
+
* '''[[RCA_AI|Default AI (RCA)]]''': This is the same AI as listed above.
** [[Experimental_AI]] details
+
* '''[[Experimental_AI]]''': Again, the same AI as described above.
 +
* Debug Mode '''Dev AIs''': If Wesnoth is in debug mode, several additional AIs are available in the menu.  For the most part, these are not meant as complete stand-alone AIs, or as AIs that are significantly different from the default AI, but rather as examples that can be used for development purposes.  {{DevFeature1.13|5}} The list of AIs has been cleaned upOnly working and (somewhat) meaningful AIs remain.
 +
* '''[[Creating Custom AIs|Custom AIs]]''':  Just as it is possible to include custom AIs in the scenario code, they can also be provided for selection from the MP setup menu.  These can be written either for specific scenarios/maps or so that they are available for all maps.
  
* '''Micro AIs''' add specialized behavior to Wesnoth that cannot be achieved by adjusting default AI parameters.  A Micro AI can be included in a scenario with a few lines of WML code, using the [[Micro_AIs#Setting_up_a_Micro_AI|[micro_ai]]] tag.
+
== Available AI Tools ==
**[[Micro_AIs]] details
 
  
* The '''Idle AI''' does nothing at all and can be chosen with [[AiWML#The_.5Bai.5D_Tag:_Defining_Aspects|ai_algorithm=idle_ai]] in the side definition.  This is generally not particularly useful and has some bugs when trying to reenable itIt is usually better to set controller=null to deactivate sides (although that also disables healing, income/uptake and side specific events).
+
The default AI is written in C++ and therefore difficult to modify directly.  However, it is a [[Wesnoth_AI_Framework#Wesnoth_AI_Framework:_A_Composite_AI|composite AI]] assembled from individual components which can be customized and modified in both WML and [[LuaWML|Lua]]Documentation on the available AI tools can be found at:
  
In addition to these AIs, Wesnoth provides a variety of options for writing you own AI code.  See the links below for details.
+
* [[AiWML]]: Customizing the default AI using WML
 +
* [[Modifying AI Components]]: More complex customization tasks and mid-scenario changes
 +
* [[Wesnoth AI Framework]]: Description of Wesnoth's composite AI configuration
 +
* [[Creating Custom AIs]]: Instructions for writing your own AI components
 +
* [[LuaAI|Lua AI]]: Recommended method for writing custom AIs
  
==A Very Brief History of Wesnoth AIs==
+
'''Notes:'''
 +
* Wesnoth has its own internal language called 'Formula' which can also be used for AI development.  It is, however, not maintained any more and has by now been surpassed by Lua in ease of use in most cases.  We therefore do not recommend using it any more, but links to the legacy documentation are still provided in the resources section below.
 +
* A Python API for AI development also existed for a while.  It was removed for security reasons.
  
While the general principle of the Wesnoth AI concept has been relatively stable throughout its development, the AI implementation has seen dramatic changes.  That said, basic scenario creator tasks such as [[AiWML|modifying AI parameters in WML]] are usually not changed much in order to keep backward compatibility.  On the other hand, the steps needed to write a custom candidate action and bind it into the existing AI framework might not be quite the same in Wesnoth 1.12 as they did in 1.10, and they are definitely different in 1.8.
+
== List of Wesnoth AI Resources ==
  
It is not possible to capture all these changes on the Wesnoth AI wiki pages due to the complexity of the topic.  They generally only refer to the latest stable release series and the current development release series.  If, for some reason, you need to do AI work with an earlier version of Wesnoth, you might have to check out the history of the wiki pages.  Another way to go about it is by checking out examples of how things are done in mainline or add-ons of the respective release series.  In general, however, we ''strongly'' recommend using the latest Wesnoth versions, as modifying AI behavior has become ''a lot'' simpler than it used to be.
+
===AI Resources for Scenario and Map Creators===
  
For reference, here is a list of some of the major milestones of the AI development:
+
* [[RCA AI]]: Description of Wesnoth's default AI, with the following additional documentation:
 +
** [[AiWML]]: Customizing the default AI using WML
 +
** [[AI Recruitment]]: Customizing the recruitment of the default AI
 +
** [[Modifying AI Components]]: Instructions for some of the more complex customization tasks
 +
* [[Experimental AI]]: Experimental augmented version of the default AI with additional features
 +
* [[Micro AIs]]: Additional specialized AI behavior that cannot be achieved with the default AI
  
[ Todo: need to verify that all this is correct and add a couple more things ]
+
===Resources for AI Coders===
  
* Wesnoth 1.6 and earlier
+
* [[Wesnoth AI Framework]]: General principles of the inner workings of the Wesnoth AI mechanism
** The default AI of Wesnoth was, in fact, called ''Default AI'', with <code>id=default_ai</code> in the configuration.
+
* [[Creating Custom AIs]]: Instructions for doing just that
* Wesnoth 1.5/1.6:
+
* [[LuaAI|Lua AI]]: Recommended method for writing custom AIs
** [[FormulaAI]] was introduced
 
* Wesnoth 1.7/1.8
 
** The concept of a [[Wesnoth_AI_Framework|composite AI framework]] was introduced, and the default AI functionality was ported to this framework in form of the [[RCA_AI]].  However, the previous AI remained the default.
 
* Wesnoth 1.9/1.10
 
** The [[RCA_AI]] became the default
 
** Further Development of [[FormulaAI]] was discontinued, although the existing Formula AI functionality remains in the code.
 
* Wesnoth 1.11/1.12
 
** Introduction of the [[Micro_AIs]]
 
** External Lua candidate actions fully usable
 
  
==AI Resources==
+
==== Legacy Resources for AI Coders====
  
Todo: flesh this out
+
* [[Lua AI Legacy Methods Howto]]: Old methods for writing custom AIs using Lua AI
 +
* [[FormulaAI|Formula AI]]: Another language for writing custom AIs
  
===AI Implementations===
+
===Miscellaneous Other Resources===
  
* [[Wesnoth_AI_Framework]]: general principle of how all Wesnoth AIs are implemented
+
The following resources are not generally needed for understanding, using and modifying Wesnoth AIs, but they might nevertheless contain some useful bits of information for the interested reader.
* Default (RCA) AI: currently described at [[General_RCA_AI_Howto]] — create new page
 
* [[LuaAI]]
 
* [[FormulaAI]]
 
* C++ and Python
 
  
===AI Resources for Scenario and Map Creators===
+
* [[AI Arena]]
 +
* [[Machine Learning Recruiter]]
 +
* [[WhyWritingAWesnothAIIsHard|Why Writing A Wesnoth AI Is Hard]]
 +
* [[WritingYourOwnAI|Writing Your Own AI]]
  
* [[AiWML]]
+
Finally, the link to the AI Category at the bottom of this page includes links to all the remaining AI-related pages.
* Other methods to modify the default AI
 
  
===AI Resources for AI Coders===
+
==A Very Brief History of Wesnoth AIs==
  
* [[Wesnoth_AI_Framework]]: General principle of how the Wesnoth AI (all AIs) work internally
+
While the general principle of the Wesnoth AI has been relatively stable throughout its development, the AI implementation has seen dramatic changes.  That said, basic scenario creator tasks such as [[AiWML|modifying AI parameters in WML]] are usually not changed much in order to keep backward compatibility.  On the other hand, the steps needed to write, for example,  [[Creating_Custom_AIs#Creating_Custom_Candidate_Actions|custom candidate actions]] and bind them into the existing AI framework have definitely evolved significantly from Wesnoth 1.8 to 1.10 to 1.12.
* [[LuaAI]]
 
* [[FormulaAI]]
 
* [[AI_Arena]]: AI testing framework [not maintained, but should be functional]
 
  
===Miscellaneous Legacy Resources===
+
It is not possible to capture all these changes on the Wesnoth AI wiki pages due to the complexity of the topic.  They generally only refer to the latest stable release series and the current development release series.  If, for some reason, you need to do AI work with an earlier version of Wesnoth, we still provide some of the legacy documentation, but you might also have to check out the history of the wiki pages.  Another way to go about it is by checking out examples of how things are done in mainline or add-ons of the respective release series.  In general, however, we ''strongly'' recommend using the latest Wesnoth versions, as modifying AI behavior has become ''a lot'' simpler than it used to be.
  
These are kept because they might be useful to those who really want to dig into the inner workings of the AI and potentially update the C++ code itself.  However, these pages are not updates any more, so they might be inaccurate and/or incomplete.
+
For reference, here is a list of some of the major milestones of the AI development:
  
* [[AI_Module]]
+
* Up to '''Wesnoth 1.6''':
* etc.
+
** The default AI of Wesnoth is, in fact, called ''Default AI'', with <code>id=default_ai</code> in the configuration.
 +
* '''Wesnoth 1.1/1.2''':
 +
** A Python API for AI development is introduced.  This was later removed for security reasons.
 +
* '''Wesnoth 1.5/1.6''':
 +
** [[FormulaAI|Formula AI]] is introduced.
 +
* '''Wesnoth 1.7/1.8''':
 +
** [[Wesnoth_AI_Framework|Composite AI framework]] is introduced, with the default AI functionality ported to this framework in the form of the [[RCA AI]].
 +
** The [[RCA AI]] becomes the default.
 +
** [[LuaAI|Lua AI]] is introduced.
 +
* '''Wesnoth 1.11/1.12''':
 +
** Introduction of the [[Micro AIs]]
 +
** External Lua candidate actions become fully usable.  They are now the recommended method for [[Creating_Custom_AIs|creating custom AIs]]
 +
* '''Wesnoth 1.15/1.16''':
 +
** Merging of most of the previous [[Experimental_AI]] candidate actions into the [[RCA AI]]
  
  
 
[[Category:AI]]
 
[[Category:AI]]

Latest revision as of 18:21, 19 July 2020

Introduction to the Wesnoth AIs

Wesnoth provides an artificial intelligence (AI) which is active by default for all computer-controlled sides, as well as several optional AIs. These AIs are highly configurable and can be included and/or customized by scenario and map creators using simple WML code. For AI developers, it is also possible to replace parts or all of the default AI with custom code.

This page provides a brief summary of the available AIs and of the methods, tools and resources available for using and modifying them. Links are provided to detailed documentation on each of the topics. For reference, we also provide a brief timeline describing some of the main development milestones of the Wesnoth AIs.

Available AIs

This section briefly lists the different AIs available in Wesnoth. Click on the links provided here and in the resources section below for detailed descriptions of the AIs and for instructions for using and customizing them.

AIs Available to Scenario and Map Designers

Wesnoth comes with several built-in AIs from which scenario and map designers can choose:

  • Default (RCA) AI: If no special instructions are given, this AI is used automatically for all computer-controlled sides with no setup needed. It can be customized in many different ways.
  • The Experimental AI adds additional features to the RCA AI. (Version 1.15.3 and later only) Several of the actions of the Experimental AI have been merged into the default AI.
  • Micro AIs add specialized behavior to Wesnoth that cannot be achieved with the default AI. There is a large number of available Micro AIs and they can be set up using just a few lines of simple WML code.
  • Custom AIs: In addition to these AIs, Wesnoth provides a large variety of options for writing your own AI code.

AIs Available in the Multiplayer Setup Menu

Several AIs are available to be chosen for computer players in the multiplayer setup menu:

  • Default AI (RCA): This is the same AI as listed above.
  • Experimental_AI: Again, the same AI as described above.
  • Debug Mode Dev AIs: If Wesnoth is in debug mode, several additional AIs are available in the menu. For the most part, these are not meant as complete stand-alone AIs, or as AIs that are significantly different from the default AI, but rather as examples that can be used for development purposes. (Version 1.13.5 and later only) The list of AIs has been cleaned up. Only working and (somewhat) meaningful AIs remain.
  • Custom AIs: Just as it is possible to include custom AIs in the scenario code, they can also be provided for selection from the MP setup menu. These can be written either for specific scenarios/maps or so that they are available for all maps.

Available AI Tools

The default AI is written in C++ and therefore difficult to modify directly. However, it is a composite AI assembled from individual components which can be customized and modified in both WML and Lua. Documentation on the available AI tools can be found at:

Notes:

  • Wesnoth has its own internal language called 'Formula' which can also be used for AI development. It is, however, not maintained any more and has by now been surpassed by Lua in ease of use in most cases. We therefore do not recommend using it any more, but links to the legacy documentation are still provided in the resources section below.
  • A Python API for AI development also existed for a while. It was removed for security reasons.

List of Wesnoth AI Resources

AI Resources for Scenario and Map Creators

  • RCA AI: Description of Wesnoth's default AI, with the following additional documentation:
  • Experimental AI: Experimental augmented version of the default AI with additional features
  • Micro AIs: Additional specialized AI behavior that cannot be achieved with the default AI

Resources for AI Coders

Legacy Resources for AI Coders

Miscellaneous Other Resources

The following resources are not generally needed for understanding, using and modifying Wesnoth AIs, but they might nevertheless contain some useful bits of information for the interested reader.

Finally, the link to the AI Category at the bottom of this page includes links to all the remaining AI-related pages.

A Very Brief History of Wesnoth AIs

While the general principle of the Wesnoth AI has been relatively stable throughout its development, the AI implementation has seen dramatic changes. That said, basic scenario creator tasks such as modifying AI parameters in WML are usually not changed much in order to keep backward compatibility. On the other hand, the steps needed to write, for example, custom candidate actions and bind them into the existing AI framework have definitely evolved significantly from Wesnoth 1.8 to 1.10 to 1.12.

It is not possible to capture all these changes on the Wesnoth AI wiki pages due to the complexity of the topic. They generally only refer to the latest stable release series and the current development release series. If, for some reason, you need to do AI work with an earlier version of Wesnoth, we still provide some of the legacy documentation, but you might also have to check out the history of the wiki pages. Another way to go about it is by checking out examples of how things are done in mainline or add-ons of the respective release series. In general, however, we strongly recommend using the latest Wesnoth versions, as modifying AI behavior has become a lot simpler than it used to be.

For reference, here is a list of some of the major milestones of the AI development:

  • Up to Wesnoth 1.6:
    • The default AI of Wesnoth is, in fact, called Default AI, with id=default_ai in the configuration.
  • Wesnoth 1.1/1.2:
    • A Python API for AI development is introduced. This was later removed for security reasons.
  • Wesnoth 1.5/1.6:
  • Wesnoth 1.7/1.8:
  • Wesnoth 1.11/1.12:
    • Introduction of the Micro AIs
    • External Lua candidate actions become fully usable. They are now the recommended method for creating custom AIs
  • Wesnoth 1.15/1.16:
This page was last edited on 19 July 2020, at 18:21.