Shipping AI

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
User avatar
skippern
Traffic Manager
Traffic Manager
Posts: 195
Joined: 30 Oct 2013 13:57

Shipping AI

Post by skippern »

I tend to play maps where shipping is good economics (FISH, lots of waterways, etc), some of these maps give difficult competition for trains and road vehicles. I would therefor like to see AI that trade with ships, in order to get stiffer competition.

I have absolutely no idea of how AI programation works, so I would depend on others to make on, or depend heavily on assistance to make one. I would definitely BETA test any such AI

If anybody know of any AI using a lot of ships, let me know.
Skippern
OpenTTD Mac user
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4765
Joined: 09 Sep 2007 05:03
Location: home

Re: Shipping AI

Post by Alberth »

It's a column in the comparison table http://wiki.openttd.org/Comparison_of_AIs

If you want to program your own AI, just have a go at it. When you have a problem people here are usually willing to give advice how to proceed.
The comparison table seems to indicate there is no AI currently that focuses on ships alone.
User avatar
skippern
Traffic Manager
Traffic Manager
Posts: 195
Joined: 30 Oct 2013 13:57

Re: Shipping AI

Post by skippern »

I had a look at the Comparison, there are a few AIs (4 if I remember correctly) that can build ships, I have them all loaded, but up until now they have built a total of 1 ship route, and the company went bankrupt short time later. That route was also first opened in 2020 or something, close to the end of the game (I remember having hover busses between the same two cities as well)

If somebody can point me in the right direction, I'll try to make a shipping focused AI, one that will try to build more shipping routes before it resolves to road vehicles. IMO there are enough AIs trying to build trains, so I will not bother there

So, can somebody show me what I need to look at in order to get an AI off the ground?
Skippern
OpenTTD Mac user
R2dical
Traffic Manager
Traffic Manager
Posts: 163
Joined: 18 Mar 2013 22:22

Re: Shipping AI

Post by R2dical »

Well firstly consider that if you have no programming experience it is a very steep (but rewarding) learning curve, but it is very possible to teach yourself what you need, at least for a Openttd AI :)

If you are serious about it, I think you should mess around a bit with a more mainstream language first to learn some basics like syntax, control structure, variables and object orientation. C++ is very well documented and popular but somewhat difficult for a beginner/casual programmer, java is another maybe easier option. There are lots of online tutorials and such, like this one for C++.

Otherwise just jump in the deep end and take it slow. The code files are compiled by OpenTTD itself, so you just need a basic IDE like Notepad++ to write the code in (though Notepad will work in a pinch too), and save the .txt files as .nut in the right directories and activate your AI in game. The wiki has lots of info for starting out.

Squirrel itself is documented, rather poorly imo, through some documentation really intended for coders with some experience already. It is somewhat similar to C++ arguably but a number of unique "features" that can be subtle and frustrating. The basics ahould be easy enough.

Keoz posted a link to another game site, which also uses Squirrel for its scripting layer. The tutorial there is geared towards beginners.

The API docs provide the code for the interface between your code and the game internals.

Once you have those down I suggest looking through some existing AIs, AdmiralAI is good for this as it is well documented and has broad use of squirrel and the API. Some things are quite outdated though, so keep this in mind.

When you are ready for your ship AI, there was an older thread where a water pathfinder was posted and could be useful.

Good luck!
User avatar
skippern
Traffic Manager
Traffic Manager
Posts: 195
Joined: 30 Oct 2013 13:57

Re: Shipping AI

Post by skippern »

Thanks for the advise R2

I have previous experience from BASIC, ANSI C, LPC (object oriented C clone), some Perl, and Java, and are in the progress of getting the basic grip of ObjC, have also been doing markups and scripting with HTML, XML, PHP, Bash, etc.

Will start playing around with the code, and see if anything useful can come out of this.
Skippern
OpenTTD Mac user
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Shipping AI

Post by Zuu »

Alberth wrote:The comparison table seems to indicate there is no AI currently that focuses on ships alone.
There is Beginner Tutorial - Ship AI which does nothing but transporting oil from two oil rigs to an refinery, but it is very specialized and doesn't do anything until it receives a trigger from the Beginner Tutorial Game Script. This Ship AI is however more or less directly based on code from the wmDOT AI which is intended to be used in normal games.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
skippern
Traffic Manager
Traffic Manager
Posts: 195
Joined: 30 Oct 2013 13:57

Re: Shipping AI

Post by skippern »

Zuu wrote:There is Beginner Tutorial - Ship AI which does nothing but transporting oil from two oil rigs to an refinery
Where do I find it? No clues for me from the download pages nor the Comparison Wikipage
Skippern
OpenTTD Mac user
R2dical
Traffic Manager
Traffic Manager
Posts: 163
Joined: 18 Mar 2013 22:22

Re: Shipping AI

Post by R2dical »

Here is the thread, but I think this is the best way to get it and the dependencies :)
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Shipping AI

Post by Zuu »

skippern wrote:
Zuu wrote:There is Beginner Tutorial - Ship AI which does nothing but transporting oil from two oil rigs to an refinery
Where do I find it? No clues for me from the download pages nor the Comparison Wikipage
You can download the tar file here: http://bananas.openttd.org/en/ai/ if you want to read its source code.

If you want to try it, get the beginner tutorial scenario and play the truck chapter without first playing the ship chapter.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
krinn
Transport Coordinator
Transport Coordinator
Posts: 342
Joined: 29 Dec 2010 19:36

Re: Shipping AI

Post by krinn »

Just to mention that many AIs have options to enable/disable vehicle type.

So an AI handling boats with other vehicle type disable won't take time to build boats as it will have no choice to make money except boats.
The next question is then how many AI have that option and boats handling. But enable/disable vehicletype feature is quiet a common option for AI.
User avatar
skippern
Traffic Manager
Traffic Manager
Posts: 195
Joined: 30 Oct 2013 13:57

Re: Shipping AI

Post by skippern »

Ok, started to play around with the code, first task, make the AI load…...
Skippern
OpenTTD Mac user
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: Shipping AI

Post by Kogut »

skippern wrote:first task, make the AI load…...
I remember doing this for two days :)

I am not sure is it going to be useful but I have example of a blank AI that is only registering itself as existing: https://github.com/Bulwersator/Test-OpenTTD-AI
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 8 guests