I have a question on AIRail.BuildSignal, the API states it has TileIndex tile, TileIndex front as parameters (and a type of course). Now if I call this function the first time, it works exactly as expected. If I call it a second time with the same parameters, I don't get an exception, but a reversed signal (analog to how the user interface works). This makes sense for the UI, but not for the API call I think. Especially given that I provide a front tile for the direction the signal is looking I don't expect a signal looking the other way because I forgot that there was already a signal there...
So the question is: is this intended behaviour and should I check for an existing signal? I think I would prefer to get an error.
Signal building
Moderator: OpenTTD Developers
-
- Engineer
- Posts: 113
- Joined: 08 Aug 2008 11:35
- Contact:
Re: Signal building
You can make your own function checking for signal and building if tile is empty. NoAI api is usually immitating GUI.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
AIAI - AI for OpenTTD
Re: Signal building
Actually I think the API should differ from the GUI when it makes sense to do that. After all the GUI and the API is just two different ways to interact with the underlying game mechanics. Each interface should make sense with respect to the underlying game mechanics but does not necessarily contain the quirks of the other interface.
A good example where the API and GUI differs is when you construct rail or road and there is an obstacle in the way. In the API the action will fail (return false) and no rail/road will be built at all. In the GUI the road/rail will be built up to the obstacle, but not continue after it. There is probably also a warning message, but I don't remember for sure. The GUI behaviour might be good for lazy users but would make it harder to write a good AI.
In this particular case, I would suggest checking the documentation to see if the implementation and docs differs. If that's the case, this could be changed as a "fix", otherwise the change will probably have to be limited to trunk and 1.1+ only.
A good example where the API and GUI differs is when you construct rail or road and there is an obstacle in the way. In the API the action will fail (return false) and no rail/road will be built at all. In the GUI the road/rail will be built up to the obstacle, but not continue after it. There is probably also a warning message, but I don't remember for sure. The GUI behaviour might be good for lazy users but would make it harder to write a good AI.
In this particular case, I would suggest checking the documentation to see if the implementation and docs differs. If that's the case, this could be changed as a "fix", otherwise the change will probably have to be limited to trunk and 1.1+ only.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
Who is online
Users browsing this forum: No registered users and 7 guests