Difference between revisions of "AI Arena"

From The Battle for Wesnoth Wiki
m (Creating new challenges)
m (fix errors (title levels))
 
(12 intermediate revisions by 4 users not shown)
Line 1: Line 1:
= AI Arena is an interactive AI testing framework =
+
{| class="wikitable" style="text-align: center;"
 +
|'''Note'''
 +
|-
 +
|The AI Arena should still be usable, but it is currently not maintained. If you encounter any problems with the Arena itself or the content of this page, please let us know either on the forums or the developer IRC channel.
 +
|}
 +
 
 +
== AI Arena is an interactive AI testing framework ==
 
It is implemented as a test scenario <i>ai_arena_small</i> (available from r34329 (31 Mar 09) )
 
It is implemented as a test scenario <i>ai_arena_small</i> (available from r34329 (31 Mar 09) )
 +
 +
This documentation is accurate as of r34889 (14 Apr 09)
  
 
To launch it, run Wesnoth with a -t parameter (must not come as last parameter). For example:
 
To launch it, run Wesnoth with a -t parameter (must not come as last parameter). For example:
Line 20: Line 28:
 
All leaders start off-map in pocketed locations.
 
All leaders start off-map in pocketed locations.
  
Human leader can access an interactive menu by stepping on the "test!" marker (6,21)
+
You can access an interactive menu by right-clicking a map tile.
  
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).  
+
There are menu options 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 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.
 
Then, the AI developer can end his turn and watch the AI's actions.
  
= Creating new challenges =
+
== Creating new challenges ==
 
Please feel free to add more 'AI challenges' and improve existing ones. Each challenge should be AI-independent.
 
Please feel free to add more 'AI challenges' and improve existing ones. Each challenge should be AI-independent.
  
While creating a challenge, do not forget about:
+
To create a challenge which will be committed into Wesnoth repository:
  
# Assign a unique number for your challenge. Insert your challenge at the end of the challenge list (so, numbers will be sorted)
+
# Look at the content ai/scenarios/ai_arena_small directory
# If you are creating multiple challenges to the same topic, you can 'nest' them in the challenge selection dialog (to let the AI developer select the topic, then select the challenge)
+
# 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
# Add code to clean all your labels to cleanup function. (since there is (so far) now way to delete all labels on the map)
+
# Create a new file in ai/scenarios/ai_arena_small directory.
# Set each side gold to be 'high enough'
+
[event]
# if it is needed, use something this like to make the other side (champion AI) passive:
+
    name=preload
  [modify_side]
+
    [lua]
    side=3
+
        code = << register_test('CODE-NAME','DESCRIPTION'); >>
    gold=10000
+
    [/lua]
    redeploy_ai_from_location=$test_path_to_idle_ai
+
  [/event]
  [/modify_side]
+
[event]
 +
    name=CODE-NAME
 +
    first_time_only=no
 +
  [/event]
  
= Creating new AI configurations =  
+
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) no way to delete all labels on the map)
 +
 
 +
== Creating new AI configurations ==  
  
 
Example of AI configuration file:
 
Example of AI configuration file:
Line 57: Line 72:
 
Then use it by typing a name in the interactive menu, or add a reference to it to the AI Arena scenario
 
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 =
+
== Where to put new AI configurations ==
  
If it should be available for selection as a multiplayer AI, put it in  
+
If it should be available for selection as a multiplayer AI and AI Arena in both non-debug and debug modes, put it in  
 
  data/ai/ais/
 
  data/ai/ais/
  
If it should NOT be available for selection as a multiplayer AI, put it in  
+
If it should be available for selection as a multiplayer AI and AI Arena only in debug mode, put it in  
 
  data/ai/dev/
 
  data/ai/dev/
  
= Where to put all formulas which may be used by the AIs=
+
== Where to put all formulas which may be used by the AIs ==
  
 
  data/ai/formula/
 
  data/ai/formula/
 +
 +
[[Category:AI]]

Latest revision as of 15:12, 30 November 2017

Note
The AI Arena should still be usable, but it is currently not maintained. If you encounter any problems with the Arena itself or the content of this page, please let us know either on the forums or the developer IRC channel.

AI Arena is an interactive AI testing framework

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

This documentation is accurate as of r34889 (14 Apr 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.

You can access an interactive menu by right-clicking a map tile.

There are menu options 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 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) no 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 and AI Arena in both non-debug and debug modes, put it in

data/ai/ais/

If it should be available for selection as a multiplayer AI and AI Arena 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/
This page was last edited on 30 November 2017, at 15:12.