Nicolas Weeger wrote:

I did a proof-of-concept for Python scripts, exporting the (location,
unit) structure to a script that just enumerates units name & position.
If people are interested I'll attach the files to a GNA patch item or
send them here.
Great. :)

* how will the script be determined? Add the script filename to map
specifications? Put the script directly in the WML data files? Have only
one file for all-purpose Python AI?
In a [side] tag, the ai_algorithm attribute specifies which AI to use. This would simply be set to python_ai to make the AI be controlled using Python scripting.

Then everything inside [ai] under the [side] tag gets exposed to the AI as parameters. So, I would suggest that there be a way to specify the script that is run in there. Then you could possibly have parameters to be passed to the script inside that. For instance,

[side]
ai_algorithm=python_ai
   [ai]
   script=myai.py
       [args]
      aggression=2.0
      recruitment=fighters,archers
       [/args]
   [/ai]
[/side]

It's likely that we would ship a decent AI (maybe multiple decent AIs) written in Python that are pluggable in case a user wants to override some of the behavior, but keep most of it the same. For instance, say a user wanted to customize the recruitment algorithm, they might do something like this:

[side]
ai_algorithm=python_ai
   [ai]
   script=standard_pluggable_ai.py
      [args]
      recruitment=myrecruit.py
      [/args]
   [/ai]
[/side]

It's possible we could also allow people to specify the Python directly into WML, rather than reference a seperate file. This would probably require WML to be extended slightly to allow quotes to be nested in it more easily.

I would say a map specifies a script, and potentially give a specific
script to a specific unit (may require some tweaks in server code,
maybe?), whether we put script in separate files or not.
I think that rather than give a specific script to a specific unit, we could make it so a set of parameters is attached to each unit (unused in most cases) which the AI can use to change behavior for that unit.

For instance, you could say, "I have made my AI, called grouping_ai. With this AI, you can use a unit's parameters section to give a 'group' parameter. My script will make units in the same group stick together."

* IMHO, Python initialization should be delayed till it's actually used
(when starting the map or at first use). This would let players use maps
with "regular AI" without making it mandatory to install Python.
I agree.

* related to previous question, should Python be mandatory? Or should
the server degrade nicely when Python isn't installed, just replacing
"ai_python" with "ai"?
I think it's fine to make Python a mandatory dependency for the game. I am hoping that we can get Python working well enough so that almost every campaign will use something depending on Python somewhere or another.

David

Reply via email to