GSoC/GCI Archive
Google Code-in 2010 The Battle For Wesnoth

AI recruitment algorithm

completed by: Grimling

mentors: Iurii Chernyi

Description

Wesnoth AI has to select what units to recruit. AI leader stands on keep and can recruit a number of units, up to the number of free hexes in his castle. AI can choose between a number of different unit types. Each unit type costs a certain amount of gold to recruit and the AI knows how good a specific unit is, and should try to recruit better unit types. AI knows how many units of a particular type it has at the moment and the scenario creators want to limit the amount of units of a certain type that the AI can have at the same time. There should be a tunable parameter that will tell the AI to go either for a mass of low-cost low-quality units or few high-cost high-quality units.

Input

  1. (integer) gold
  2. (integer) maximum number of units to be recruited
  3. (double) quantity vs quality - 0 means 'go for mass of low-quality units', 1 means 'go for few high-quality units), and other values are in between
  4. table of potential recruits
    1. (string) recruit name
    2. (integer) cost to recruit
    3. (double) how good each unit is
    4. (integer) current quantity
    5. (integer) maximum quantity

Output

a list of units to be recruited.

Example input

  1. AI has 120 gold
  2. Up to 5 units are to be recruited
  3. go for quality (1.0)
  4. table of potential recruits
Recruit name Cost to recruit How good this unit is Current Qty Maximum Qty
Spearman 13gp 12.6 1 10
Royal Guard 30gp 40.0 0 2

Example output

Royal Guard, Royal Guard, Spearman, Spearman, Spearman

(we go for quality but we can recruit up to 2 royal guards, so the rest of 5 units are spearmans)

Difficulty

Should not be too difficult. But, you need to know either C++ or lua, and you need to think out and code a good algorithm for picking out the units to be recruited.

Deliverable/expected proof

We will provide a incomplete program that provides the correct input and you must complete it, coding a suitable recruitment algorithm.

http://wiki.wesnoth.org/GCI/Recruitment