Binary path for python AI in campaigns
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.
Binary path for python AI in campaigns
(This is for 1.5.10, in which python AI should work, according to the changelog)
I just want to find out how I could use my own python AI in my campaign. I have written it up nicely but I couldn't quite figure out how the game would recognise the existence of the .py file. With the python AI that comes with the game, I can do this to utilise them:
But if I use my own python AI, which I have saved under userdata/data/campaigns/mycampaign/ai/python, I thought all I needed to do is to set a binary path like this in my main cfg file:
But that didn't work. The stderr.txt would say that it cannot find my python file. So I tried what's been suggested by ReferenceWML:
Unfortunately this didn't work either. I wonder if anyone would know how do use your own python AI script which is saved in the campaign folder.
I just want to find out how I could use my own python AI in my campaign. I have written it up nicely but I couldn't quite figure out how the game would recognise the existence of the .py file. With the python AI that comes with the game, I can do this to utilise them:
Code: Select all
[ai]
ai_algorithm=python_ai
python_script=bruteforce.py
[/ai]
Code: Select all
[binary_path]
path=data/campaigns/mycampaign/ai/python
[/binary_path]
So I added this to the main cfg file:* python_script: is used when ai_algorithm has the value python_ai, and specifies the name of the python script the AI should use. The script is looked for in the same pathes as units, specified with binary_path.
Code: Select all
[+units]
{@campaigns/mycampaign/ai/python}
[/units]