GSoC/GCI Archive
Google Code-in 2012 Copyleft Games Group

Wesnoth: Serialize parameter transfer to Micro AIs

completed by: gh0st

mentors: Nils Kneuper, AI0867, Alarantalara, mattsc

wesnoth
lua

A number of AIs have recently been converted to Micro AIs. The transfer of configuration parameters to the Micro AIs is currently done manually in the *_CAs.lua files, which is both somewhat cumbersome and restrictive. We want to enable the use of more complex configuration elements, such as Standard Location Filters.

To accomplish this, automatic serialization of the cfg table to a string should be used. A function ai_helper.serialize() is available for this and the Healer Support and Bottleneck Defense AIs have already been changed and can be used as examples/templates.

The task is completed when all current Micro AIs have been converted to use automatic cfg serialization. Depending on how many parameters are transferred and how the existing engine code is set up, this task involves:

  • Setting up the cfg table for the AI in micro_ais_wml_tags.lua and serializing it.
  • Transferring the config string to the *_CAs.lua files. Note: only one cfg_str shall be used per file even if the different evaluation and execution functions take different sets of parameters. Transferring parameters to a function that are not needed is not a problem.
  • In some cases, the AI engine functions need to be adjusted to take a single input parameter, the cfg table, rather than a series of individual inputs.
  • The names of the parameters used by the engine functions need to be the same as those used in the [micro_ai] tag. In some AIs, the parameter names need to be changed for this to be the case.

Documentation about Micro AIs in general and GCI Micro AI tasks are available on the Wesnoth wiki.