Because how you wish implement that in your AI it would be hard to answer your question, per example, you didn't tell us if building a station near another one is a wanted feature or an unexpected/unlucky one and problematic for you.
- If building next to a station isn't a problem, you don't really have to check if it's a station or not, but if the tile is usable : it depend again on what you wish your AI to be able to do :
* i need a road, any : so just test if it's a road in front
* i need a road, but i must own it : test if it's a road and owner
* i need a place where i could build a road : then test if it's buildable
* i need a place where i will be able to build a road : it's the hardest part, a water tile won't be buildable as-is, but with investing money, it would. The heuristic to find what conditions you find acceptable for your AI is the key.
- If building next to a station is a problem, IsStationTile is enough to answer you, see my loop at line 159 :
http://dev.openttdcoop.org/projects/ai- ... uilder.nut and "voisin" is french for neighbor
- If building next to a station you own isn't a problem (to extend a previous station per example), then you need to detect the station, the ownership of the station and that station ID too.