Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Tue Oct 24, 2017 2:17 am

All times are UTC




Post new topic  Reply to topic  [ 1 post ] 
Author Message
PostPosted: Fri Sep 29, 2017 1:50 pm 
Offline
Engineer
Engineer

Joined: Mon May 31, 2010 9:06 pm
Posts: 37
A lot of people are writing AI and GS scripts with little to nothing in tools to help debug some rather complicated programs.

I felt like this already way back in 2010 when I developed an interactive debugger that I used heavily back then. The problem was that it requires a fair number of modifications to OTTD to make the built-in Squirrel debugger work. The original thread can be seen here: https://www.tt-forums.net/viewtopic.php?f=65&t=51612

I want to try and reintegrate that code with the current version of OTTD, but a lot has changed since 2010. In particular, the debug window code has seen a major rewrite. For the debugger to work, it needs to be able to get input from the user and as you can see on the screenshot in the above link, I used an input line at the bottom of the debug window. I also added a function - AIController.GetDebugInput - that could be called from a script to get the input.

What I need is someone to give me an idea how to go about adding an input line to the debug window and how to add the GetDebugInput function so it will work in AI and GS scripts. I think I can do the rest, but if someone more familiar with the code could do this part, it would save me a lot of time. (I need actual code - not where to look :)

I also think that the capability to provide input to a running script should be a standard feature in trunk, as it would allow for the examination of variables at run-time, without having to put Log statements everywhere.

The last time RL interrupted my involvement with OTTD, but now I should be able to devote more time to it. If I can get the debugger working, I will make it available to the community.

If you are interested in seeing how this worked on r21365, I have included two zip files from Windows 7:
- OpenTTD.zip should replace your OpenTTD folder in Documents. Make a copy of your current one first.
- OpenTTD - old.zip contains the modified openttd.exe that can run the debugger and all the files needed to run the game, my ai (YATT) and ATTDebug.
To see some examples of a debug session, see some of the ATTDebug log files in this folder.

Everything should be set up for you, just run the game and create a new game, will be in Pause mode...
Open the AI debug window - should be blank...
Unpause the game and accelerate time until the AI starts - it will stop at line 104 in cATT\Main and ATTDebug will be in control
At this point you can enter ATTDebug commands in the input line. Enter the following commands in order:
show calls // Displays the call stack
type 100:110 // Lists the source code line 100 to 110
examine s_cfg // Displays contents of table s_cfg
step/into // Executes the instruction on line 104 and steps into the first function called
sh c // Can abbreviate commands
s // Step
ex engid

You get the idea :)

To see the ATTDebug documentation, download the ATTDebug_1_0.zip file from the page linked above.


Attachments:
OpenTTD-old.zip [18.43 MiB]
Downloaded 7 times
OpenTTD.zip [5.3 MiB]
Downloaded 8 times

_________________
Attila
"Artificial intelligence is no match for natural stupidity."
Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: Baidu [Spider] and 1 guest


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-2017 phpBB Limited

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