http://noai.openttd.org/docs/trunk/ai__changelog_8hpp.html wrote:1.1.0
API removals:
* HasNext for all lists.
Some API extension ideas
Moderator: OpenTTD Developers
Re: Some API extension ideas
That is documented already on the AI changelog page for quite some time:
Re: Some API extension ideas
Is the 0.7.5 API compatibility being phased out? Guess I'll bite the bullet and update to 1.0 for the next release.
Re: Some API extension ideas
and the point i was asking was that it didn't work back then...Yexo wrote:That is documented already on the AI changelog page for quite some time:http://noai.openttd.org/docs/trunk/ai__changelog_8hpp.html wrote:1.1.0
API removals:
* HasNext for all lists.

AroAI - A really feeble attempt at an AI
It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra
It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra
Re: Some API extension ideas
Eventually it'll be, but if it's not too much work we'll try and keep it working for some time.Michiel wrote:Is the 0.7.5 API compatibility being phased out? Guess I'll bite the bullet and update to 1.0 for the next release.
Re: Some API extension ideas
and AIEngine.GetWeightOfFullyLoaded(engine_id)Kogut wrote:- AIVehicle.GetWeight(vehicle_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
There is
But there is not:
Code: Select all
AIMap::DistanceMax ( TileIndex tile_from, TileIndex tile_to)
Code: Select all
AIMap::DistanceMin ( TileIndex tile_from, TileIndex tile_to)
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
I have a question to the problem with HasNext() <> IsEnd():
Does the following code work right with all versions? It's using IsEnd() when the version is 1.1 or higher.
function hasnext(list) {
if (::major>1||(::major>0&&::minor>0))return !list.IsEnd();
return list.HasNext();
}
I want to call it with hasnext(list) instead of list.hasnext(). Maybe some experts have better solutions for this, but it is ok when it work as it should.
Does the following code work right with all versions? It's using IsEnd() when the version is 1.1 or higher.
function hasnext(list) {
if (::major>1||(::major>0&&::minor>0))return !list.IsEnd();
return list.HasNext();
}
I want to call it with hasnext(list) instead of list.hasnext(). Maybe some experts have better solutions for this, but it is ok when it work as it should.
Re: Some API extension ideas
Just make sure your info.nut GetAPIVersion returns "1.0" and always use HasNext(). That is by far the easiest solution. Otherwise your code looks ok.
Re: Some API extension ideas
Thanks for your answer Yexo.
I don't really understand what you mean when you say that I should always use HasNext() when GetAPIVersion returns 1.0.
I think this is the same as it was before. The problem is that GetAPIVersion not returns 1.0 in the newer OpenTTD versions and what you have to do then. I think you always have to decide between HasNext() and IsEnd() if you want to keep compatibility to all OpenTTD versions.
But when you say my code looks ok, I think I let it, as it is.
I don't really understand what you mean when you say that I should always use HasNext() when GetAPIVersion returns 1.0.
I think this is the same as it was before. The problem is that GetAPIVersion not returns 1.0 in the newer OpenTTD versions and what you have to do then. I think you always have to decide between HasNext() and IsEnd() if you want to keep compatibility to all OpenTTD versions.
But when you say my code looks ok, I think I let it, as it is.
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: Some API extension ideas
You don't really have to support the 0.7 API anymore. The VAST majority of players uses 1.0.0 or better meanwhile.Steffl wrote:Thanks for your answer Yexo.
I don't really understand what you mean when you say that I should always use HasNext() when GetAPIVersion returns 1.0.
I think this is the same as it was before. The problem is that GetAPIVersion not returns 1.0 in the newer OpenTTD versions and what you have to do then. I think you always have to decide between HasNext() and IsEnd() if you want to keep compatibility to all OpenTTD versions.
But when you say my code looks ok, I think I let it, as it is.
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
Re: Some API extension ideas
When you return 1.0 for GetAPIVersion HasNext will work, however if you do so in a recent trunk version then IsEnd will work as well. This means that under trunk while returning 1.0 for GetAPIVersion you can technically use both, however when the AI is ran under 1.0 it will not be having IsEnd and as such not work.Steffl wrote:I don't really understand what you mean when you say that I should always use HasNext() when GetAPIVersion returns 1.0.
So, when you return 1.0 for GetAPIVersion you must not use IsEnd and always use HasNext, which is what Yexo wanted to get across.
Re: Some API extension ideas
Ahhh, sorry I think it's my fault that we talked in different directions. 
I don't have described what I mean with ::major and ::minor.
They are the major and minor version number from AIController.GetVersion(), not from AIInfo.GetAPIVersion ().
My question is:
If OpenTTD version is 1.1 our higher, you have always to use IsEnd(), on older versions you can/have to use HasNext()? Like I did in the code below.
Thanks for your help.

I don't have described what I mean with ::major and ::minor.
They are the major and minor version number from AIController.GetVersion(), not from AIInfo.GetAPIVersion ().
My question is:
If OpenTTD version is 1.1 our higher, you have always to use IsEnd(), on older versions you can/have to use HasNext()? Like I did in the code below.
Thanks for your help.
Re: Some API extension ideas
In 1.1 API HasNext is removed. Fortunatelly special script transform HasNext function in 1.0 API AIs to IsEnd.
In other words:
1.1 API, 1.1 API declared: IsEnd()
1.1 API, 1.0 API declared: HasNext() (I see that it is NOT working)
1.0 API (or lower): HasNext ()
======
Yet Another Request: AIRail.GetRailwayTypeName(railway_type)
======
@Yexo (and maybe others?) Thanks for developing NoAI API!
======
In other words:
1.1 API, 1.1 API declared: IsEnd()
1.1 API, 1.0 API declared: HasNext() (I see that it is NOT working)
1.0 API (or lower): HasNext ()
======
Yet Another Request: AIRail.GetRailwayTypeName(railway_type)
======
@Yexo (and maybe others?) Thanks for developing NoAI API!
======
Kogut wrote:I tried to use AIRail::BuildNewGRFRailStation ( http://noai.openttd.org/api/0.7.3/class ... 2262c8b42f ).
But I see:
IndustryType source_industry,
IndustryType goal_industry
What with industry to town / town to town routes?
frosch wrote:Towns are 0xFF.
Seems like there is no enumeration for that
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
Request:
AIController::GetWindowDisplayVersion()
or something similar or, modify the existing AIController::GetVersion()
to display whatever is displayed in the toolbar at the top of the screen (see pic)
AIController::GetWindowDisplayVersion()
or something similar or, modify the existing AIController::GetVersion()
to display whatever is displayed in the toolbar at the top of the screen (see pic)
- Attachments
-
- untitled.gif (5.54 KiB) Viewed 8174 times
AroAI - A really feeble attempt at an AI
It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra
It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra
Re: Some API extension ideas
Kogut wrote:I tried to use AIRail::BuildNewGRFRailStation ( http://noai.openttd.org/api/0.7.3/class ... 2262c8b42f ).
But I see:
IndustryType source_industry,
IndustryType goal_industry
What with industry to town / town to town routes?
r20108 adds AIIndustryType::INDUSTRYTYPE_TOWN and AIIndustryType::INDUSTRYTYPE_UNKNOWN which can be passed to AIRail::BuildNewGRFRailStation for towns resp. if there is no specific industrytype (e.g. multiple industries).frosch wrote:Towns are 0xFF.
Seems like there is no enumeration for that
Also note that the API now checks the passed industrytype for validity (previously it just passed the stuff on to the grf). So check your AIs whether they still work

⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
Re: Some API extension ideas
Great!
Yet Another Request: AIRail.GetRailwayTypeName(railway_type)
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
Can we get a function that returns the station id or the station tile of the cargo origin?
Something like TileIndex AIVehicle.GetCargoOrigin(VehicleID,CargoID)
We have this information displayed for buses carrying passengers. I want to know if my fleet of buses on their way to a station have enough capacity to take the cargo. The problem is when vehicles are already at the station, I can't tell if the load they are carrying is to be unloaded or picked up already.
Alternately, a function that returns the state of a vehicle in more detail may be of use:
ie: Instead of just being at a station, break it down to Loading/Unloading
Something like TileIndex AIVehicle.GetCargoOrigin(VehicleID,CargoID)
We have this information displayed for buses carrying passengers. I want to know if my fleet of buses on their way to a station have enough capacity to take the cargo. The problem is when vehicles are already at the station, I can't tell if the load they are carrying is to be unloaded or picked up already.
Alternately, a function that returns the state of a vehicle in more detail may be of use:
ie: Instead of just being at a station, break it down to Loading/Unloading
Attila
"Artificial intelligence is no match for natural stupidity."
"Artificial intelligence is no match for natural stupidity."
Re: Some API extension ideas
Request: GetNextNearestTown()
for finding the nearest town to town_a (or whatever)
for finding the nearest town to town_a (or whatever)
AroAI - A really feeble attempt at an AI
It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra
It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra
Re: Some API extension ideas
Is there a reason why we have AIVehicle.GetRefitCapacity, but we don't have AIEngine.GetRefitCapacity?
I want to make a decision about which engine to buy, but can't tell how much cargo I will be able to carry without actually buying the vehicle.
I want to make a decision about which engine to buy, but can't tell how much cargo I will be able to carry without actually buying the vehicle.
Attila
"Artificial intelligence is no match for natural stupidity."
"Artificial intelligence is no match for natural stupidity."
Re: Some API extension ideas
Yes... OpenTTD has no way of knowing the refit capacity of an "engine" as it can only execute the refit callback on actual vehicles. As such OpenTTD would need to build the vehicle before it can test it... but wait... there is more... the (refit) capacity of a part of a vehicle (wagon, engine) can depend on other parts within the same consist and that effectively makes AIEngine.GetRefitCapacity useless as you won't be getting the right numbers.Attila7 wrote:Is there a reason why we have AIVehicle.GetRefitCapacity, but we don't have AIEngine.GetRefitCapacity?
Who is online
Users browsing this forum: No registered users and 15 guests