Creating AIs

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
Seven11
Engineer
Engineer
Posts: 11
Joined: 04 Nov 2014 02:02

Creating AIs

Post by Seven11 »

I'm kind of new to OpenTTD, and I got to say, the AIs are very talented :D . But I was wondering how it is done, like how are they created? I wanted to see if I could get some advice from someone who knows how. It would be appreciated!
krinn
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 29 Dec 2010 19:36

Re: Creating AIs

Post by krinn »

The base are there. http://wiki.openttd.org/AI:Main_Page

AI use squirrel v2 (if i'm right openttd use 2.2) http://www.squirrel-lang.org/doc/squirrel2.html

AI have their API : http://noai.openttd.org/docs/trunk/

You can get your code host there http://dev.openttdcoop.org/projects/aidev

And you can use the bananas service to upload your AI to openttd users : http://bananas.openttd.org/en/ai/


Best way imo is look for an AI that only use roads (because it's the simplest transport to handle), and look at its code to learn.
ps: simpleai now is not as simple as it use to be, but that was one of the AI that help me a lot when start mine, just make SURE and CERTAIN Brumi (simpleai's author) will not test your AI and you'll be fine (else you will get your first bug report)
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Creating AIs

Post by Zuu »

When you got something working and want to show and get feedback, create a new thread in this subforum dedicated to your AI. Whenever you upload it to bananas, it is common to use this thread as "website" for the AI.

As such you can use the bananas web interface (or in-game) and click on the website link to get to their forum thread.

If you start out by copying an existing AI, the most important fields to change in info.nut is Name and ShortName, as these are used for save/load and bananas ID. After uploading to bananas, these typically never changes later. Also mind to follow the license of the AI you start from if you copy an existing AI. Most use GPL2 but there are some exceptions.


Edit: It is also a good idea to enable gui.ai_developer_tools. This is detailed in the wiki section that krinn linked you to. It is a good idea to browse that section to at least get an overview of the topics in there. Some you will want to dig deeper into as well.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 5 guests