SoC Ideas AI Recruitment 2012

From The Battle for Wesnoth Wiki
Revision as of 17:06, 9 March 2012 by Crab (talk | contribs) (Description)


This page is related to Summer of Code 2012
See the list of Summer of Code 2012 Ideas



This is a Summer of Code 2012 Idea


Description

AI: Refactor recruitment algorithm

Page for the idea: SoC_Ideas_AI_Recruitment_2012

We need to refactor existing wesnoth's recruitment algorithm to:

  1. support recruiting with multiple leaders.
  2. support per-leader recruit/recall lists.
  3. support easy limiting of recruitable units.
  4. analyze map terrain better
  5. recruit units that are more useful
  6. improve counter-recruiting strategies.
  7. improve recruiting for AI-playable campaigns where AI has to not spend all the gold.

There are 4 submitted student proposals for this idea

Aline Riss Recruitment Proposal

For the moment, AI recognize only one leader even if he has more. Moreover, the recruitment algorithm is very basic. So we can set the list of possible amelioration below:

  • support recruiting with multiple leaders
  • support per-leader recruit/recall lists.
  • support easy limiting of recruitable units.
  • analyze map terrain better
  • recruit units that are more useful
  • improve counter-recruiting strategies.
  • improve recruiting for AI-playable campaigns where AI has to not spend all the gold.

In order to treat these problematic, I have highlight two points which will be my principals axes for this project and will be treat separately :

  • The placement of leaders
  • The recruitment algorithm

Each point are, at begin, independent for each other.

First, I will treat the recruitment algorithm which is the principal problem of this project. It's only in a second part that I will treat the placement problem.
See GSoC Akihara Proposal for more information.

Kseniya Buraya - Refactoring AI Recruitment

The project is to improve current AI recruiting system. I will develop and implement these options:

  • To recruit with a lot of leaders instead of one
  • To consider the terrain type where the possible battle will be
  • To consider enemy and allied units together as to create great counter-unit mix
  • To provide the scenario editor an option to choose recruiting strategy ("defensive", "agressive", etc.) and to set limits on particular units


See SoC 2012 HappyKsuh AI Recruitment for more information.

Talbot Pierre - Refactor Recruitment Algorithm

The current recruitment algorithm is based on a WML recruitment pattern which specify the recruitable units. Apart for scout, no real strategy is established because most of the units are chosen randomly from this pattern list.

I'll dedicate my summer around three axes:

  • Multiple leaders: We must manage a list of leaders and free keeps, to affect each leader to a keep and change it if needed (because it's too far from the battle...). AI should choose where an unit (on which castle) will be recruited to be more efficient, taking into account the number of enemy units and their weaknesses.
  • Recruiting better units: The units must be chosen for a specific purpose such as getting a village, fighting a specific unit, protecting another... AI should be able to keep in mind the original purpose of an unit to take further decisions. By the way, this design should be discuss with the community and the other GSoC participants because it has a large impact on the entire AI.
  • WML parameterisation: The recruitment pattern will be improved to allow scenario editors to be more specific on which units should be recruited.


See Soc2012 Talbot Pierre Refactor Recruitment Algorithm for more information.

Paolo De Luca - Refactoring recruitment algorithm

Refactoring recruitment algorithm as stated in the proposed ideas. I think those points are quite enough yet. However I would consider to detail what I've intended for "recruit units that are more useful" for I suppose it's highly connected with the rest of AI playstyle. Different behaviour based on

  • current map;
  • AI mission objetives: chase, retire, kill specific units;
  • initial Time of Day;
  • distance from enemy;
  • allies (which will repeat the above points if it's an AI);
  • current and future gamestyle ( aggressive/defensive) MUST include the fact that AI have to switch between them;


See Soc2012 Teugon Refactor Recruitment Algorithm for more information.

Additional Information

Recruiting is important for both player and AI. Units are recruited each turn.

We now have an implementation of recruiting routine, which tries to recruit units which are good in combat against units already in the field, taking into account the entire map. But, there are a number of issues, and we want to solve them.

1) AI only uses first leader to recruit - but, if there are multiple leaders, it might be useful to recruit with all of them.

2) AI cannot use per-leader recruit lists - but, leaders can have unique recruit lists (ask fendin about this feature).

3) Scenario editors want the AI recruit all units or most of the units, even if some of them might seem suboptimal from 'combat' point of view, but, as AI only considers combat/movement 'for the entire map', it might miss units which seem suboptimal. An example situation is where a unit has a specific role in the strategy, serving as auxiliary unit or as a hard counter to some specific opponent unit.

4) One of the tool that scenario editors usually use to make the AI recruit more diverse units (and also for limiting difficulty), is limiting the number of concurrent recruits of specific type in the field. Now they are doing it via a WML macro - it's better if recruiting would allow parameterization, allowing scenario creators to easily specify some 'what to recruit' hints and limitations. An example would be 'consider recruiting water-based because I want this leader to control the waterways' or 'recruit enough scouts in the first three turns because I want the AI to start capturing more villages early'. The optimal number of scouts varies with the map, of course.

5) This leads to another problem - if AI recruits some units thinking of particular purpose, it must use them properly - i.e., if a fish is recruited, it should not be used to move it to land to fight - otherwise, it makes little sense to recruit the fish in the first place'

6) Several years ago we tried an approach where the AI was finding 'most important' hexes on map and using the terrain on those hexes to affect it's recruitment patterns (instead of using the entire map)

7) Recruiting first is a huge disadvantage, because of possibility to recruit counters to enemy units. So, if the AI recruits first, it should recruit to minimize the potential for counter-recruiting (i.e., by making a balanced army which can't be hard countered by enemy potential recruits)

8) Sometimes it makes sense to hold back and not recruit even if gold is available - for example, if you're playing a campaign and current scenario is already 'beaten', or if you're waiting for the enemy to recruit units to counter them. This makes sense for the AI which usually defends and which usually wins if time runs out - so, the AI can afford to let the player come to it's position, so, it can afford to recruit some scouts and wait for the human to approach before committing to specific types of units. Also, AI has problems with grouping units so if units are recruited one-by-one, they would be would not be sent in a group.

Whom to ask about this

Crab_ on irc.