Station near industry

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
bri
Engineer
Engineer
Posts: 7
Joined: 06 Oct 2011 15:54

Station near industry

Post by bri »

Hello,

here is another question I have: I want to build a station near a industry, so that I can get and deliver goods. As I already know, the position of the Industry is the tile on the top right. But how can I find out the possible tiles I can build a station. From playing the game I know, that there is a maximum of 3 tiles beetween station and industry, so the station should be build at maximum 4 tiles away from the industry: So my fist idea was:
local area=AITileList();
area.AddRectangle(industry_tile-AIMap.GetTileIndex(4,4),industry_tile+AIMap.GetTileIndex(4,4));
But this doesn't concern the size of the industry. So there are two questions:

a) How can I find out the size of an industry?
b) Is the maximum distance between station and industrie alwaly 4 tiles or is there any function giving me this constant for my AI?
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Station near industry

Post by Yexo »

a) You use AITileList_IndustryAccepting and AITileList_IndustryProducing
b) it depends on the station coverage radius.
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: Station near industry

Post by Kogut »

Small suggestion - you can download existing AIs and reuse code.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Station near industry

Post by Zuu »

Mind which license they use. All(?)/most AIs on BaNaNaS use some kind of open source license, but not all of them are compatible and thus it depends on which license you pick yourself, which AIs that you can copy code from.

Another option is to use libraries. In that case you don't have to copy the code but instead just include the library and thus don't have to care about license conflicts. For Road you find several useful functions in SuperLib. For Aircraft there is also some, but only for building stations near Towns (not industries). SuperLib also contains lots of functions for general problems not specific to any transport mode.
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 11 guests