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

Wesnoth: Micro AI 'Random Recruit'

completed by: Martin Bede

mentors: Nils Kneuper, Alarantalara, mattsc


A number of Wesnoth AIs have recently been converted to Micro AIs. Another AI that is often requested is one doing a random recruit. The basic code for such an AI (albeit not in form of a Micro AI), has been proposed in this Wesnoth forum thread (second post in the thread).

The goal of this task is to turn this Random Recruit AI code into a functioning Micro AI, using the existing Micro AIs as templates. In addition, two tests need to be added to the code: whether the side leader is on the keep, and whether there is an empty hex available for recruiting on. Both tests are present in the do_recruit_eval() function in lua/generic-recruit_engine.lua, though the empty hex code is more complicated than needed since that AI reuses the intermediate results. Also, a parameter should be added to the [micro_ai] tag that lets the user select from two possible behaviors in low-gold situations: select from entire recruit list and recruit nothing if not enough gold, or select only from affordable units.

Random recruiting should be added as a parametrization of the existing recruiting Micro AI by introducing a recruit_type= key, rather than by creating an entirely new Micro AI.  Check out the Guardian or Animals Micro AIs for examples how that can be done.

The task is completed when the Random Recruit Micro AI has been implemented and tested (use the Recruiting scenario provided in AI-Demos for this) and this has been documented on the Wesnoth wiki.

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