Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Sat May 25, 2019 12:10 pm

All times are UTC




Post new topic  Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Thu Apr 30, 2009 8:31 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed Jun 06, 2007 9:07 pm
Posts: 1710
Location: Czech Republic
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


Attachments:
ai_debug-16188.patch [3.83 KiB]
Downloaded 213 times
ai_debug-19627.patch [3.59 KiB]
Downloaded 153 times

_________________
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)


Last edited by Bilbo on Wed Apr 14, 2010 2:09 pm, edited 1 time in total.
Top
   
PostPosted: Thu Apr 30, 2009 10:53 pm 
Offline
Transport Coordinator
Transport Coordinator

Joined: Thu Feb 07, 2008 2:06 pm
Posts: 378
Location: Glasgow
Hi Bilbo,

I like this patch. I haven't check it yet, but I like the idea. It will make development a lot easier this way, at least it will limit the time spend searching / diagnosing a torrent of prints to the debug window. I'm not sure if it's such a good idea to print the data in the command window, the debug screen has the advantage of having a scroll bar which is very convenient for reading through your logs.

Nice work :)!


Top
   
PostPosted: Fri May 01, 2009 9:01 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed Jun 06, 2007 9:07 pm
Posts: 1710
Location: Czech Republic
The plan is that command will print the return value (if any) - so it will be up to AI author where will the debug info end up (AI console, regular console, or maybe both :) If the function won't return anything, nothing will be printed.

Note that you can scroll the console too (Shift+pageup, shift+ pagedown, shift+up, shift+down), so I don't think not having scroollbars is any issue :)

_________________
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)


Top
   
PostPosted: Wed Apr 14, 2010 2:11 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed Jun 06, 2007 9:07 pm
Posts: 1710
Location: Czech Republic
I've updated the patcdh to newest trunk (r19627).
Get the updated patch in the first post.

_________________
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2019 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2019.
Hosted by Zernebok Hosting.