AI Arena

From The Battle for Wesnoth Wiki
Revision as of 23:36, 13 April 2009 by Crab (talk | contribs) (Where to put new AI configurations)

AI Arena is an interactive AI testing framework

It is implemented as a test scenario ai_arena_small (available from r34329 (31 Mar 09) )

To launch it, run Wesnoth with a -t parameter (must not come as last parameter). For example:

./wesnoth-debug -t ai_arena_small -d

The scenario is located in data/ai/scenarios/scenario-AI_Arena_small.cfg

It is based on the Den of Onis.

The map includes three sides:

1: Human (AI developer)

2: Challenger AI (Side which which is tested, 'north team')

3: Champion AI (Side which commands the enemy of the AI being tested, 'south team')

All leaders start off-map in pocketed locations.

Human leader can access an interactive menu by stepping on the "test!" marker (6,21)

There is an interactive menu which allows AI developer to pick the challenge (each challenge has a small description and a unique number), and to pick the AI that will try the challenge (AI developer can select from a list or input a .cfg location which contains the bare *contents* of the SIDE tag with SideWML and AiWML configuration - without the SIDE tag itself). The test will be loaded (units will appear inside the Arena) and selected AI will be hot-redeployed).

Then, the AI developer can end his turn and watch the AI's actions.

Creating new challenges

Please feel free to add more 'AI challenges' and improve existing ones. Each challenge should be AI-independent.

To create a challenge which will be committed into Wesnoth repository:

  1. Look at the content ai/scenarios/ai_arena_small directory
  2. Assign a unique CODE number (4 digits) for your challenge. Pick a NAME (suitable as part of WML event name) for your challenge. Write a small DESCRIPTION for your challenge
  3. Create a new file in ai/scenarios/ai_arena_small directory.
[event]
    name=preload
    [lua]
        code = << register_test('CODE-NAME','DESCRIPTION'); >>
    [/lua]
[/event]
[event]
    name=CODE-NAME
    first_time_only=no
[/event]

Use the second event to create the situation. If you do not intend to commit that file, you may use any filename and event name you like, just make sure that this is legal WML event name and make sure that it matches in both events.

Note: Add code to clean all your labels to cleanup function. (since there is (so far) now way to delete all labels on the map)

Creating new AI configurations

Example of AI configuration file:

ai_algorithm =formula_ai
[ai]
   eval_list=yes
   [register_candidate_move]
       name=poisoner
       type=attack
       evaluation="{ai/formula/poisoner_eval.fai}"
       action="{ai/formula/poisoner_attack.fai}"
   [/register_candidate_move]
[/ai]

Then use it by typing a name in the interactive menu, or add a reference to it to the AI Arena scenario

Where to put new AI configurations

If it should be available for selection as a multiplayer AI in both non-debug and debug modes, put it in

data/ai/ais/

If it should be available for selection as a multiplayer AI only in debug mode, put it in

data/ai/dev/

Where to put all formulas which may be used by the AIs

data/ai/formula/