AI Problem

Discuss the new AI features ("NoAI") introduced into OpenTTD 0.7, allowing you to implement custom AIs, and the new Game Scripts available in OpenTTD 1.2 and higher.

Moderator: OpenTTD Developers

Post Reply
DeletedUser6
Transport Coordinator
Transport Coordinator
Posts: 294
Joined: 23 Jul 2007 15:13
Location: Somewhere in this page

AI Problem

Post by DeletedUser6 »

I have been having trouble with my homemade AI. It is based on the wiki tutorial with the addition of it being updated to be named Gamma. Anyway, I can't get OTTD (0.7.5 mac) to detect it. I've followed the introduction tutorial page to the letter and it doesn't detect it. On an unrelated note it also detects only CluelessPlus 307, even when I have updated it to 322 and removed the old binary, a similar thing happening with AIAI, only that it doesn't detect it at all.

Will upload screenie of detection problem and my info.nut and main.nut soon.

edit: Doesn't detect CluelessPlus at all now.
Attachments
Picture 2.pdf
No Gamma, AIAI or CluelessPlus
(377.56 KiB) Downloaded 104 times
info.nut
info.nut
(547 Bytes) Downloaded 83 times
main.nut
main.nut
(195 Bytes) Downloaded 95 times
Yay! I'm back! Did you miss me?


...


I thought not.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: AI Problem

Post by Zuu »

IIRC, CluelessPlus has never existed as version "307".

The class you have in info.nut can not be named the same as the class you have in main.nut. Try to rename the "Gamma" class in your info.nut to "FGamma".


Please upload pictures as png-files so that one do not need to use acrobat reader to view your image.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
DeletedUser6
Transport Coordinator
Transport Coordinator
Posts: 294
Joined: 23 Jul 2007 15:13
Location: Somewhere in this page

Re: AI Problem

Post by DeletedUser6 »

I'll try it out, thanks.

edit: Same result as before.
idea1: Should I put it in the squirrel folder and then move it?
idea2: Should I zip the folder as I've put it in content_download/ai?
Maybe someone should put the above in the wiki as it didn't mention what you said.
Yay! I'm back! Did you miss me?


...


I thought not.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: AI Problem

Post by Zuu »

Regarding what I said before, I've looked in the wiki and I'm unsure if I'm correct regarding that limit. From a programmers point of view I find it strange to have two classes having the same name though there could be some scoping magic going on in OpenTTD since neither the info nor the main file include the other in your code.

I have my AI development files in

Documents\OpenTTD\Installations\Last Nightly\ai\<some ai>\main.nut
Documents\OpenTTD\Installations\Last Nightly\ai\<some ai>\info.nut
Documents\OpenTTD\Installations\Last Nightly\ai\<some ai>\...


Where "Documents\OpenTTD\Installations\Last Nightly" is the path to my "last nightly" install. This way the development versions only show up when I use the nightly version of OpenTTD. Of course, you will need to find out the path to your 0.7.5 installation if you want to use this method. If you want them to show up on any OpenTTD installation then put them in:

Documents\OpenTTD\ai\main.nut
Documents\OpenTTD\ai\info.nut
Documents\OpenTTD\ai\..

If I remember correctly what I've been told, there is a "Documents" folder on MacOSX and to OpenTTD Documents/OpenTTD/ is equivalent to Documents\OpenTTD\ on Windows Vista/7 and ~/.openttd/ on Linux.

If any folder do not exist, you may create it.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
fanioz
Transport Coordinator
Transport Coordinator
Posts: 320
Joined: 19 Dec 2008 05:03
Location: Indonesia
Contact:

Re: AI Problem

Post by fanioz »

Debug wrote: Your script made an error: the index doesn't exist

CALLSTACK
*FUNCTION [main()] gamma\info.nut line [13]

LOCALS
[this] TABLE
dbg: [misc] [squirrel] Failed to compile 'D:\Data\OpenTTD\ai\gamma\info.nut'
fixed: see attachment
Attachments
info.nut
fixed info.nut
(558 Bytes) Downloaded 79 times
screenshot#1.png
screenshot#1.png (10.76 KiB) Viewed 1593 times
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: AI Problem

Post by Zuu »

What fanoz didn't tell you, but could be useful to know is that if the AI fails to compile it will not show up in the AI list and you can't see the compile error messages in the game. Instead you have to start Openttd with the flags "-d ai=5" and take a look in the console window to find the error message from compiling your AI. It might be necessary to increase the number of lines that the console remembers in Windows if you haven't increased the 300-line limit on your system yet.

Edit: See the wiki for screenshots and more info: http://wiki.openttd.org/AI:Need_To_Know ... sole_Usage
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
DeletedUser6
Transport Coordinator
Transport Coordinator
Posts: 294
Joined: 23 Jul 2007 15:13
Location: Somewhere in this page

Re: AI Problem

Post by DeletedUser6 »

Thank you very much fanioz and Zuu. I am a bit closer to making a useable AI that might work!

edit: It loads and then crashes on startup with no debug info. Fixed: Removed the company naming piece of code I added (from the wiki of course).

edit2: Crashes when I use the road and rail Pathfinder.
Yay! I'm back! Did you miss me?


...


I thought not.
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 4 guests