Page 10 of 16

Re: Some API extension ideas

Posted: 12 Jul 2010 17:09
by Attila7
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?

Re: Some API extension ideas

Posted: 20 Jul 2010 10:58
by Attila7
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.

Re: Some API extension ideas

Posted: 20 Jul 2010 18:11
by Lord Aro
are you ever going to release this AI of yours? it sounds really good :wink:
</offtopic>

Re: Some API extension ideas

Posted: 21 Jul 2010 15:02
by frosch
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

Posted: 21 Jul 2010 17:19
by Attila7
So, how do you propose to handle the detection of the situation?

Re: Some API extension ideas

Posted: 22 Jul 2010 11:33
by svetovoi
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

Posted: 22 Jul 2010 11:43
by Attila7
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.

Re: Some API extension ideas

Posted: 10 Aug 2010 01:20
by fanioz
If it was possible to get these value...

Re: Some API extension ideas

Posted: 18 Aug 2010 18:00
by Lord Aro
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 :D

------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)

Re: Some API extension ideas

Posted: 18 Aug 2010 18:03
by Yexo
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 :D
GetMonth() and GetDayOfMonth() return integers, not strings.
Lord Aro wrote:Request: GetNextNearestTown()
There already is AITile::GetClosestTown
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)
I see no reason to implement this.

Re: Some API extension ideas

Posted: 18 Aug 2010 18:14
by Lord Aro
Yexo wrote:
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 :D
GetMonth() and GetDayOfMonth() return integers, not strings.
damn
Yexo wrote:
Lord Aro wrote:Request: GetNextNearestTown()
There already is AITile::GetClosestTown
but in the circumstances described (vaguely) above, that would just return town_a
Yexo wrote:
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)
I see no reason to implement this.
oh go on... you know you want to... :lol: why not? it would be a better version than AIController.GetVersion() (if you ask me, but i concentrate on the aesthetics of the debug output too much)

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... :lol:

Re: Some API extension ideas

Posted: 19 Aug 2010 03:20
by fanioz
Lord Aro wrote:
Yexo wrote:
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 :D
GetMonth() and GetDayOfMonth() return integers, not strings.
damn
Hey.. you could use AILibrary - String that handle Date function.

->

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 
*/
Want to take only a part ?
use CLString.Split to split the date based on separator.
look more : here

Re: Some API extension ideas

Posted: 19 Aug 2010 13:17
by Brumi
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?

Re: Some API extension ideas

Posted: 19 Aug 2010 13:46
by fanioz
Brumi 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?
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 value

Code: Select all

void AIList::ChangeItem(int32 item, int32 value)
{
   this->SetValue(item, value);
}

Re: Some API extension ideas

Posted: 12 Nov 2010 08:59
by Kogut
What about GetRailTypeName(RailType rail_type)?

Re: Some API extension ideas

Posted: 12 Nov 2010 21:43
by Kogut
And bool AIInfo::UseAsReplacementAI (like bool AIInfo::UseAsRandomAI ) - to fix problems like this: http://www.tt-forums.net/viewtopic.php?p=913027#p913027

Re: Some API extension ideas

Posted: 28 Nov 2010 20:11
by Hephi
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

Re: Some API extension ideas

Posted: 28 Nov 2010 20:14
by Yexo
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

Posted: 29 Nov 2010 22:53
by Yexo
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

Posted: 29 Nov 2010 23:06
by Kogut
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)