How to specify a python AI in a scenario ?

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
viorc
Posts: 130
Joined: February 22nd, 2006, 3:03 am

How to specify a python AI in a scenario ?

Post by viorc »

I am trying to apply one of the simple python AI I got to a selfmade scenario. But it does not work. Even if I try to specify the python AI as distributed with wesnoth (sample.py), the same error message occurs.

From the information got in the WML reference page of the wiki, I have tried the lines:

Code: Select all

[side]
        side=2
        [ai]
                ai_algorithm=sample.py
        [/ai]
[/side]
but at runtime, the log gives me the message: "error ai: AI not found: 'sample.py'"

I am running the Battle for Wesnoth v1.3-svn on linux.
The script sample.py can be found on both /usr/local/share/wesnoth/data/ais and ~/.wesnoth/data/ais/. As a test, when I run multiplayer game, I can pick up this sample.py AI for the computer from the list provided in the interface (and run it !).
Does WML use another list of AI than the interface of the multiplayer game setting ?
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Post by Sapient »

did you try "sample_ai"?
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
User avatar
allefant
Units Database Administrator
Posts: 516
Joined: May 6th, 2005, 3:04 pm

Re: How to specify a python AI in a scenario ?

Post by allefant »

viorc wrote:Does WML use another list of AI than the interface of the multiplayer game setting ?
Yes, it does use another list. As the wiki does say, you need to do:

Code: Select all

controller=ai
[ai]
ai_algorithm=python_ai
python_script=sample.py
[/ai]
sample.py will be found in any path specified by [binary_path], the order for these pathes is the same one as used for units. Best practice is probably to give it a campaign specific name, but I'm not too sure, never tried it yet.
viorc
Posts: 130
Joined: February 22nd, 2006, 3:03 am

Re: How to specify a python AI in a scenario ?

Post by viorc »

allefant wrote:As the wiki does say, you need to do:

Code: Select all

controller=ai
[ai]
ai_algorithm=python_ai
python_script=sample.py
[/ai]
Thanks allefant. Sorry for missing that part on the wiki.
Should you update that page http://www.wesnoth.org/wiki/AiWML too or put a link to the python AI wiki page ?
User avatar
allefant
Units Database Administrator
Posts: 516
Joined: May 6th, 2005, 3:04 pm

Re: How to specify a python AI in a scenario ?

Post by allefant »

viorc wrote: Thanks allefant. Sorry for missing that part on the wiki.
Should you update that page http://www.wesnoth.org/wiki/AiWML too or put a link to the python AI wiki page ?
Thanks, I added it there as well.
Post Reply