Some API extension ideas
Moderator: OpenTTD Developers
Re: Some API extension ideas
I would like to request (again).
AIVehicle::
-GetRailType
-GetPlaneType
Reason: can't getting these through AIEngine, when the engine is no longer buildable.
AIVehicle::
-GetRailType
-GetPlaneType
Reason: can't getting these through AIEngine, when the engine is no longer buildable.
Re: Some API extension ideas
I need that as well (plane type). I'm not sure if there are more things that are only available in the engine that you would want to check after the engine has disappeared. Maybe it is a better solution to make all engines valid always (or at least after they are no longer buildable) and then have a separate check function for if the engine can be built or not.fanioz wrote:I would like to request (again).
AIVehicle::
-GetRailType
-GetPlaneType
Reason: can't getting these through AIEngine, when the engine is no longer buildable.
It would be very nice if we could get away with this message from the API doc
Some kind of promised compatibility layer would be awesome. This would mean that you can more extensively check for settings without the fear of them changing in future.API doc wrote:AIGameSettings::IsValid and AIGameSettings::GetValue are functions that rely on the settings as OpenTTD stores them in savegame and openttd.cfg. No guarantees can be given on the long term validity, consistency and stability of the names, values and value ranges. Using these settings can be dangerous and could cause issues in future versions. To make sure that a setting still exists in the current version you have to run AIGameSettings::IsValid before accessing it.
I would be happy to see the possibility to supply vehicle types to eg. AIVehicleList_Station to have that filtered already. If that is added it should probably also be added to the other AIVehicleList_*. I notice that there is no AIVehicleList_Waypoint while there is a AIWaypointList_Vehicle (corresponding to the AIStationList_Vehicle).
I would love to see (but I think these things do not need to make any particular stable version since it is enough to have them on the version used by AI-developers):
- Make some AI settings configurable in-game (eg. place debug signs) - faster than having to traverse a long list of signs for "enable_signs" every time you want to place/update a sign
- In the AI Debug window, add a text box where you can input a break string. Each AILog message is matched against this break string and if there is a match, the game pauses. (just simply check if the typed string is a sub string of the log string)
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
Re: Some API extension ideas
Just giving a status update:
To summarize:
Some function to query the cost of building various things will be added before 1.0 (edit: done in r18955)
Todo:
Needs some more fundamental changes to the servicing system, will probably have to wait until after 1.0Yexo wrote:[*]AIVehicle::ChangeServicingInterval
=> not planned for 1.0[*]Check vehicles/stations belonging to other companies (FS#2776) - not planned for 0.8
Implemented[*]Load latest version of AI that can load the data, don't load exact same version first. (FS#3232)
Implemented[*]Keep is-random-ai flag when an AI is started, so don't start the same AI every time for a random slot. (FS#3095)
Work in progress, expect this soon[*]AIGameSettings::GetBaseCost(price_index) with a list of valid price indexes.
Still thinking about this one.fanioz wrote:request for AIEventVehicleHasVoidOrder.
Not implemented, but the AIEngine functions now work even if the engine is no longer buildablefanioz wrote:I would like to request (again).
AIVehicle::
-GetRailType
-GetPlaneType
Reason: can't getting these through AIEngine, when the engine is no longer buildable.
AIVehicleList_Station also works for waypoints (in 1.0, not in 0.7).Zuu wrote:I would be happy to see the possibility to supply vehicle types to eg. AIVehicleList_Station to have that filtered already. If that is added it should probably also be added to the other AIVehicleList_*. I notice that there is no AIVehicleList_Waypoint while there is a AIWaypointList_Vehicle (corresponding to the AIStationList_Vehicle).
Implemented[*] Make some AI settings configurable in-game (eg. place debug signs) - faster than having to traverse a long list of signs for "enable_signs" every time you want to place/update a sign
Patch by Zuu on flyspray.[*] In the AI Debug window, add a text box where you can input a break string. Each AILog message is matched against this break string and if there is a match, the game pauses. (just simply check if the typed string is a sub string of the log string)
To summarize:
Some function to query the cost of building various things will be added before 1.0 (edit: done in r18955)
Todo:
- Break AI on specific string (patch done by Zuu)
- ChangeServicingInterval (probably won't make 1.0)
- Check vehicles/stations belonging to other companies (probably won't make 1.0)
- AIEventVehicleHasVoidOrder (not sure if this is really needed)
Re: Some API extension ideas
Regarding my patch:
IIRC it works okay if you don't mind it finish the current tick before breaking the AI and pausing the game. So to be useful for debugging code you need to put a Sleep call after the print-statement that you are looking for. That means that you need to modify the AI source code in order to make good use of this patch.
To avoid bug reports and confusion I think it would be worth to invest a few hours to see how hard it would be to make it break the AI after the AILog call and then OpenTTD would continue to run to the end of the tick and will then pause. If it is very hard, then it might not just be worth it, but I think I/we should at least take a look.
IIRC it works okay if you don't mind it finish the current tick before breaking the AI and pausing the game. So to be useful for debugging code you need to put a Sleep call after the print-statement that you are looking for. That means that you need to modify the AI source code in order to make good use of this patch.
To avoid bug reports and confusion I think it would be worth to invest a few hours to see how hard it would be to make it break the AI after the AILog call and then OpenTTD would continue to run to the end of the tick and will then pause. If it is very hard, then it might not just be worth it, but I think I/we should at least take a look.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
Re: Some API extension ideas
Yup, this would be only an equal notifier for AI that human player had.Yexo wrote:Still thinking about this one.fanioz wrote:request for AIEventVehicleHasVoidOrder.
........
AIEventVehicleHasVoidOrder (not sure if this is really needed)
an AI writer could just check whether a destination order for each vehicles are still valid, instead of waiting an event triggered. So you're right.
However, thanks for another feature introduced. Great
Re: Some API extension ideas
I'd like to request a console command for printing the current variables of an AI, either to the console or the AI debug window. Or a command like 'crash_ai' to crash an AI manually (those red lines in the AI debug window can be really useful). It could be useful if an AI gets into an infinte loop.
What do you think?
What do you think?
Re: Some API extension ideas
I think it is a good idea. I have though about it myself but haven't got around to ask for it or trying to implement it.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
Re: Some API extension ideas
lol, i thought the command 'print' sends the log to my epson sx100
Re: Some API extension ideas
We could do this ourselves if we were still allowed to call getroottable(). Why was that taken away?
PathZilla - A networking AI - Now with tram support.
Re: Some API extension ideas
Excellent !Yexo wrote:Just giving a status update:
Re: Some API extension ideas
I know this is very late and may possible not be for 1.0 but later.
1) Get the annually maintenance cost of having transport mode at a station.
2) Get the build cost of stations/depots/waypoints
[edit]3) Get figures from the economy window for estimating how quick the company will earn X amount of money[/edit]
1. IIRC in 1950 you pay about 500 pounds a year for each transport mode available at a station. This I guess change by inflation and the base value could possible change in future and/or the way inflation works so it would be nice to have a function to access this cost.
2. Since there has been added functions to get the price of building road without having some flat land to test on perhaps functions for getting the building cost of stations road/rail/air etc. could be added as well?
[edit]3. When choosing if an AI should wait for money to buy something expansive it will help to know the maintenance cost and vehicle income. For vehicles an AI could obtain this by summing up the stats for each vehicle, but not for stations as station maintenance costs are not available to the AI unless the suggestion above is implemented.[/edit]
(I'm doing some work to get PAXLink to do some cost/benefit analysis of actions before spending all money on the first action and maybe even learning to save money for higher revenue investments)
1) Get the annually maintenance cost of having transport mode at a station.
2) Get the build cost of stations/depots/waypoints
[edit]3) Get figures from the economy window for estimating how quick the company will earn X amount of money[/edit]
1. IIRC in 1950 you pay about 500 pounds a year for each transport mode available at a station. This I guess change by inflation and the base value could possible change in future and/or the way inflation works so it would be nice to have a function to access this cost.
2. Since there has been added functions to get the price of building road without having some flat land to test on perhaps functions for getting the building cost of stations road/rail/air etc. could be added as well?
[edit]3. When choosing if an AI should wait for money to buy something expansive it will help to know the maintenance cost and vehicle income. For vehicles an AI could obtain this by summing up the stats for each vehicle, but not for stations as station maintenance costs are not available to the AI unless the suggestion above is implemented.[/edit]
(I'm doing some work to get PAXLink to do some cost/benefit analysis of actions before spending all money on the first action and maybe even learning to save money for higher revenue investments)
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
Re: Some API extension ideas
Yexo, did you look for a solution about vehicles which can handle several cargos at the same time ?
Re: Some API extension ideas
- AICompany.IsTownOwner(company_id) - So that you can determine if something is owned by a company or a town.
- Either AIRoad.CanRemoveRoad[Full]Completely or make AIRoad.RemoveRoad[Full] return false unless the entire length of road can be removed. As a player you can see if a vehicle is in the way, but for AIs you would have to loop through all your vehicles and check if they match the list of tiles that will have the road removed. And even then, you can only check your own vehicles, not vehicles owned by other companies.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
Re: Some API extension ideas
AIIndustry.IsStrangeIndustry(industry_type_id)
- is it industry interacting in weird way with environment - for example: tropical lumber mill
- that exclude stocpiling
- AIIndustry.WhatCargoIsNeededToProceedBeforeThatCargo(industry_type_id, cargo_id) (return - cargo list)
- for example ECS machine works require steel to proceed glass
- tourist centre require tourists to proceed goods
-AIIndustry.IsIndustrySuppliedWithCargo(industry_id, cargo_id)
- is it industry interacting in weird way with environment - for example: tropical lumber mill
- that exclude stocpiling
- AIIndustry.WhatCargoIsNeededToProceedBeforeThatCargo(industry_type_id, cargo_id) (return - cargo list)
- for example ECS machine works require steel to proceed glass
- tourist centre require tourists to proceed goods
-AIIndustry.IsIndustrySuppliedWithCargo(industry_id, cargo_id)
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
AIAI - AI for OpenTTD
Re: Some API extension ideas
Openttd doesn't have that information for industries defined by newgrfs.Kogut wrote:AIIndustry.IsStrangeIndustry(industry_type_id)
- is it industry interacting in weird way with environment - for example: tropical lumber mill
- that exclude stocpiling
Openttd doesn't have that information for industries defined by newgrfs.- AIIndustry.WhatCargoIsNeededToProceedBeforeThatCargo(industry_type_id, cargo_id) (return - cargo list)
- for example ECS machine works require steel to proceed glass
- tourist centre require tourists to proceed goods
Is this information in any way available to human players? Other then by looking at their competitors vehicles? If not, then it's a duplicate of FS#2776-AIIndustry.IsIndustrySuppliedWithCargo(industry_id, cargo_id)
Re: Some API extension ideas
1) And it is impossible/very hard to do to "ask" newgrf about industry properties? And return it through noai api?
2) So is it possible to check for added newgrf?
Possible use - use ony PAX cargo when somebody added ECS vectors.
2) So is it possible to check for added newgrf?
Possible use - use ony PAX cargo when somebody added ECS vectors.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
AIAI - AI for OpenTTD
Re: Some API extension ideas
That is possible, but only if a newgrf supported that. Currently there is no way for a newgrf to provide that information, it'd need an extension of specs, and even then it wouldn't be complete in all cases.Kogut wrote:1) And it is impossible/very hard to do to "ask" newgrf about industry properties? And return it through noai api?
Then your AI wouldn't work if an updated grf had another grfid. This has been suggested and denied before.2) So is it possible to check for added newgrf?
Re: Some API extension ideas
Is it possible to examine callbacks for "strange features"? //It may be very stupid question, I even don't know how callbacks work in openttd.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
AIAI - AI for OpenTTD
Re: Some API extension ideas
Another idea:
there is BuildNewGRFRailStation
is it possible to have BuildNewGRFTileWithWaitingCargo
or even BuildNewGRFTileWithBuilding?
use: extending station coverage using rail station in looking-like-no-cheat-and-stupid-exploit way.
there is BuildNewGRFRailStation
is it possible to have BuildNewGRFTileWithWaitingCargo
or even BuildNewGRFTileWithBuilding?
use: extending station coverage using rail station in looking-like-no-cheat-and-stupid-exploit way.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
AIAI - AI for OpenTTD
Re: Some API extension ideas
Something more important:
There is already AIIndustry.GetStockpiledCargo() but for ECS it is useless without AIIndustry.GetMaxStockpileSize().
There is already AIIndustry.GetStockpiledCargo() but for ECS it is useless without AIIndustry.GetMaxStockpileSize().
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 4 guests