I created patch to aid with AI debugging.
It adds console command debug_ai - first parameter is number of company, or "c" for current company, rest of the prameters are the debugging parameters.
The command will call Debug() method in the main AI class, passing rest of the parameters as specified on the commandline as strings.
for example,
Code:
ai_debug 1 p1 blah
will call
Code:
Debug("p1","blah"); on AI controller in first company.
It also adds alias "ad", that will call "debug_ai c" and pass the rest of the parameters - intended usage of the alias is that you use cheat to switch to company you wish to debug and they you type just "ad" in console to save some keystrokes.
Some example of how the Debug() function may look like:
Code:
function Debug(...) {
if (vargc<1) {
print("Need at least one parameter")
return;
}
print("Debug called");
for(local i = 0; i< vargc; i++) print("parameter "+i+" = "+vargv[i]);
}
What the Debug() call will actually do is up to the AI author - it can print out some of its variables, test something, run some internal debugging, change its settings in runtime, whatever ...
Advantage is, that AI using these debug features can run even with unpatched OpenTTD without any modifications - you just won't be able to take advantage of calling the Debug() function...
Planned future improvements:
Print return value in console (so you can see response in the game console, which could be slightly more comfortable than having the AI debug console with the target AI opened)
So .... what are your oppinions about this patch?
Edit: update to newest trunk