Some API extension ideas
Moderator: OpenTTD Developers
Re: Some API extension ideas
Perhaps we could have the routine return the refit capacity for road vehicles, ships and planes, but not trains. These are the vehicle types that need this most and for these types the return values should be accurate, no?
Attila
"Artificial intelligence is no match for natural stupidity."
"Artificial intelligence is no match for natural stupidity."
Re: Some API extension ideas
I just got to the point in my AI where it started to transport goods to a town. At some point a message popped up that said the station no longer accepts goods and my trucks would run around without unloading.
It would be very useful to get an Event for this that the AI can detect.
It would be very useful to get an Event for this that the AI can detect.
Attila
"Artificial intelligence is no match for natural stupidity."
"Artificial intelligence is no match for natural stupidity."
Re: Some API extension ideas
are you ever going to release this AI of yours? it sounds really good
</offtopic>

</offtopic>
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
I don't know. The problem with the notification about station's acceptance changes is that industries with stockpiling trigger them every few days. I.e. when stockpile is filled and somewhat emptied again.
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
Re: Some API extension ideas
So, how do you propose to handle the detection of the situation?
Attila
"Artificial intelligence is no match for natural stupidity."
"Artificial intelligence is no match for natural stupidity."
Re: Some API extension ideas
You may just check AITile.GetCargoAcceptance(..., cargo_id, ...) for station tiles from time to time, and when it is < 8 for all tiles => station do not accept cargo_id anymore.
Re: Some API extension ideas
I realize that, but what would take the game engine running in C++ a few instructions to do (as it is already doing the work of detection and popping up the message), the AI will have to also do - on every station/cargo combination. This will surely use more resources than just checking the event queue.
Attila
"Artificial intelligence is no match for natural stupidity."
"Artificial intelligence is no match for natural stupidity."
Re: Some API extension ideas
If it was possible to get these value...
- Attachments
-
- Unnamed, 5th Oct 1998.png (38.43 KiB) Viewed 7773 times
Re: Some API extension ideas
just a thought and entirely non-essential, perhaps make AIDate.GetMonth() and AIDate.GetDayOfMonth() always return 2 digits, eg: 01, 02 ...10...31 etc
just a thought to make my debug output look neater
------Others-not-yet-talked-about-------
just a thought to make my debug output look neater

------Others-not-yet-talked-about-------
Lord Aro wrote:Request: GetNextNearestTown()
for finding the nearest town to town_a (or whatever)
Lord Aro wrote: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)
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
GetMonth() and GetDayOfMonth() return integers, not strings.Lord Aro wrote:just a thought and entirely non-essential, perhaps make AIDate.GetMonth() and AIDate.GetDayOfMonth() always return 2 digits, eg: 01, 02 ...10...31 etc
just a thought to make my debug output look neater
There already is AITile::GetClosestTownLord Aro wrote:Request: GetNextNearestTown()
I see no reason to implement this.Lord Aro wrote: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)
Re: Some API extension ideas
damnYexo wrote:GetMonth() and GetDayOfMonth() return integers, not strings.Lord Aro wrote:just a thought and entirely non-essential, perhaps make AIDate.GetMonth() and AIDate.GetDayOfMonth() always return 2 digits, eg: 01, 02 ...10...31 etc
just a thought to make my debug output look neater
but in the circumstances described (vaguely) above, that would just return town_aYexo wrote:There already is AITile::GetClosestTownLord Aro wrote:Request: GetNextNearestTown()
oh go on... you know you want to...Yexo wrote:I see no reason to implement this.Lord Aro wrote: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)

more:
AICompany.[Get/Set]CompanyColour();
AICompany.IsSecondCompanyColourUsed();
AICompany.[Get/Set]SecondCompanyColour();
AICompany.[Get/Set]PresidentFace(*company-id*, *newgrf-style-input*); (if you get what i mean, like what is stored in openttd.cfg)
Like i said, i concentrate to the looks of my AI far too much...

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
Hey.. you could use AILibrary - String that handle Date function.Lord Aro wrote:damnYexo wrote:GetMonth() and GetDayOfMonth() return integers, not strings.Lord Aro wrote: just a thought and entirely non-essential, perhaps make AIDate.GetMonth() and AIDate.GetDayOfMonth() always return 2 digits, eg: 01, 02 ...10...31 etc
just a thought to make my debug output look neater![]()
->
Code: Select all
import("AILib.String", 1, "CLString");
CLString.Date(date, date_format, separator) ;
/*
Convert date to it string representation
Parameters:
date
Date integer to convert
date_format
One of DateStr Format :
DateYMD = Year - Month - Day
DateMDY = Month - Day - Year
DateDMY = Day - Month Year
separator
separator for each section. eg, 12.10.12 or 31/12/10
Returns:
string of date
*/
use CLString.Split to split the date based on separator.
look more : here
Re: Some API extension ideas
I think if there are notifications for new industries being founded, there should be some AIEventTownFounded as well. And I think this should be available as a news item for players as well...
EDIT: Sorry for being a bit off-topic, I don't want to open a new topic for this: What is the difference between AIAbstractList::SetValue() and AIList::ChangeItem(), apart from the return value?
EDIT: Sorry for being a bit off-topic, I don't want to open a new topic for this: What is the difference between AIAbstractList::SetValue() and AIList::ChangeItem(), apart from the return value?
Re: Some API extension ideas
Well, I don't think there would be a different, since AIList::ChangeItem() call AIAbstractList::SetValue() in it implementation, except that AIList::ChangeItem() doesn't return the return valueBrumi wrote:EDIT: Sorry for being a bit off-topic, I don't want to open a new topic for this: What is the difference between AIAbstractList::SetValue() and AIList::ChangeItem(), apart from the return value?
Code: Select all
void AIList::ChangeItem(int32 item, int32 value)
{
this->SetValue(item, value);
}
Re: Some API extension ideas
What about GetRailTypeName(RailType rail_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
And bool AIInfo::UseAsReplacementAI (like bool AIInfo::UseAsRandomAI ) - to fix problems like this: http://www.tt-forums.net/viewtopic.php?p=913027#p913027
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
Not really an extension but a very small change to the api doc
for AIEngine.GetWeight()
Get the weight of an engine.
Is this always unloaded or does it change when the load of the wagon changes?
I know it returns the empty weight when going over the engine_list and that is what counts for me
but the API doc doesn't elaborate on this.
edit:
removed another question
for AIEngine.GetWeight()
Get the weight of an engine.
Is this always unloaded or does it change when the load of the wagon changes?
I know it returns the empty weight when going over the engine_list and that is what counts for me
but the API doc doesn't elaborate on this.
edit:
removed another question
Last edited by Hephi on 28 Nov 2010 20:31, edited 2 times in total.
--------------------------------------------------
MailAI, a casual postal service for openTTD.
--------------------------------------------------
MailAI, a casual postal service for openTTD.
--------------------------------------------------
Re: Some API extension ideas
The argument is an EngineID, which cannot refer to a specific vehicle, only to a vehicle type (=engine type). As such it's always the empty weight.
Re: Some API extension ideas
I lost track in this topic. It would be very much appreciated if someone could make a list of suggestions that haven't been rejected yet so I can take a look at them and implement some.
Re: Some API extension ideas
GetRailTypeName(RailType rail_type)
TownEffectCargoDeliveredToCity(AICargo::TownEffect, town_id) //water, food available for player and tracked by openttd so it can be: WaterCargoDeliveredToCity, FoodCargoDeliveredToCity
AIMap::DistanceMin ( TileIndex tile_from, TileIndex tile_to)
TownEffectCargoDeliveredToCity(AICargo::TownEffect, town_id) //water, food available for player and tracked by openttd so it can be: WaterCargoDeliveredToCity, FoodCargoDeliveredToCity
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
Who is online
Users browsing this forum: Ahrefs [Bot] and 22 guests