Script/exe to test ai's

Discussion of all aspects of the game engine, including development of new and existing features.

Moderator: Forum Moderators

Post Reply
dagoi-koi
Posts: 15
Joined: October 30th, 2007, 4:55 am

Script/exe to test ai's

Post by dagoi-koi »

I have written a script that is used to test ai's on Windows. It automates the launching of wesnoth.exe with the parameters you specify in an .ini file and collects the data into a text file. When first run it creates an .ini file with the following parameters that can be changed.

Code: Select all

[Options]
Ai1=bruteforce.py
Ai2=sample.py
Output_Filename=autoplayer.output.txt
[Factions]
Use_Factions=no
Ai1_Faction=Knalgan Alliance
Ai2_Faction=Knalgan Alliance
[Maps]
MultipleMaps=no
Map=multiplayer_Den_of_Onis, multiplayer_The_Freedlands, multiplayer_Weldyn_Channel
The script prompts for input on the number of rounds you want the ai's to play, plays that number of rounds(per map if multipleMaps=yes), compiles the results, and outputs the results to a text file.

Sample Results with input of 5:

Code: Select all

Match 1: winner: 1 (using bruteforce.py)  
Match 2: winner: 1 (using bruteforce.py)  
Match 3: winner: 1 (using bruteforce.py)  
Match 4: winner: 2 (using sample.py)  
Match 5: winner: 1 (using bruteforce.py)  
Map = multiplayer_Den_of_Onis
bruteforce.py went first
bruteforce.py wins = 4
sample.py wins = 1
Draws = 0
---------------
The code is written in autohotkey. http://www.autohotkey.com/ If you have autohotkey installed then you can use the attached autoplayer.ahk.txt and remove the .txt suffix. Otherwise you will need the compiled exe .

The compiled executable can be downloaded at: http://hyperfileshare.com/d/435afa03

Either way the file should be placed in the directory where BFW is installed. The .ini file and the output are then created in that directory.

So now its easy to play 50 games and analyze the results. I hope this helps in the development of better ai's.

EDIT: Just tried this on 1.3.9 and because BFW sometimes crashes at end of scenario and doesn't exit then this script also cannot finish. So until Wesnoth no longer goes into linger mode and must be manually killed, don't use it on the development version.

EDIT(2): Now works with 1.3.10. Uploaded new version with support for multiple maps and choosing factions. Updated download link with new version.
Attachments
autoplayer.ahk.txt
Code written in autohotkey. To use, place in Wesnoth directory, and remove the .txt suffix. *Must have autohotkey installed.*
(3.09 KiB) Downloaded 350 times
Screenshot of input screen.
Screenshot of input screen.
autoplayer.png (5.93 KiB) Viewed 1800 times
Post Reply