Shipping AI
Moderator: OpenTTD Developers
Shipping AI
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.
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
OpenTTD Mac user
Re: Shipping AI
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.
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.
Re: Shipping AI
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?
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
OpenTTD Mac user
Re: Shipping AI
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!

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!
Re: Shipping AI
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.
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
OpenTTD Mac user
Re: Shipping AI
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.Alberth wrote:The comparison table seems to indicate there is no AI currently that focuses on ships alone.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
Re: Shipping AI
Where do I find it? No clues for me from the download pages nor the Comparison WikipageZuu wrote:There is Beginner Tutorial - Ship AI which does nothing but transporting oil from two oil rigs to an refinery
Skippern
OpenTTD Mac user
OpenTTD Mac user
Re: Shipping AI
You can download the tar file here: http://bananas.openttd.org/en/ai/ if you want to read its source code.skippern wrote:Where do I find it? No clues for me from the download pages nor the Comparison WikipageZuu wrote:There is Beginner Tutorial - Ship AI which does nothing but transporting oil from two oil rigs to an refinery
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)
Junctioneer (a traffic intersection simulator)
Re: Shipping AI
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.
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.
Re: Shipping AI
Ok, started to play around with the code, first task, make the AI load…...
Skippern
OpenTTD Mac user
OpenTTD Mac user
Re: Shipping AI
I remember doing this for two daysskippern wrote:first task, make the AI load…...

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
AIAI - AI for OpenTTD
Who is online
Users browsing this forum: No registered users and 8 guests