Some API extension ideas

Discuss the new AI features ("NoAI") introduced into OpenTTD 0.7, allowing you to implement custom AIs, and the new Game Scripts available in OpenTTD 1.2 and higher.

Moderator: OpenTTD Developers

Post Reply
Blustuff
Engineer
Engineer
Posts: 112
Joined: 21 Aug 2008 09:37
Location: France

Re: Some API extension ideas

Post by Blustuff »

I didn't find functions to get/set name of stations. I wanted to get the generated station name to make vehicle group name. So this is another extension idea.
User avatar
1009
Engineer
Engineer
Posts: 81
Joined: 22 Mar 2009 07:24
Location: Haarlem, The Netherlands
Contact:

Re: Some API extension ideas

Post by 1009 »

Blustuff wrote:I didn't find functions to get/set name of stations. I wanted to get the generated station name to make vehicle group name. So this is another extension idea.
Look into Denver & Rio Grande source code. It renames it's stations. So does TransAI.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Some API extension ideas

Post by Yexo »

Blustuff wrote:I didn't find functions to get/set name of stations. I wanted to get the generated station name to make vehicle group name. So this is another extension idea.
AIBaseStation is a superclass of AIStation. As such, all AIBaseStation functions (GetName/SetName/etc.) also work for AIStation.

The above information only holds for trunk. In 0.7 there is no AIBaseStation and GetName/SetName are functions of AIStation.
svetovoi
Engineer
Engineer
Posts: 87
Joined: 12 Oct 2007 14:07

Re: Some API extension ideas

Post by svetovoi »

Why the API does not have function like AIVehicle::SetServiceInterval(vehicle_id, days)?
It was never requested before, or there is another reason?
Hope name is clear and explain function's purpose.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Some API extension ideas

Post by Yexo »

ac84 wrote:Why the API does not have function like AIVehicle::SetServiceInterval(vehicle_id, days)?
It was never requested before, or there is another reason?
Hope name is clear and explain function's purpose.
It has been suggested before: http://bugs.openttd.org/task/2853

The reason that it's not included yet is that the trunk code is buggy and that needs to be solved first. I've gathered ideas on how to fix it but never got around to implementing a fix.
Chruker
Engineer
Engineer
Posts: 49
Joined: 01 Jun 2009 20:13

Re: Some API extension ideas

Post by Chruker »

Could use a function like AIStationList_Vehicle but for depots, so that I can see if any vehicles have specific a depot as part of their orders.

It'll be fine if it also includes vehicles that are currently heading towards the depot (either ordered of because or service interval).
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Not Very Important but I need it

Post by Kogut »

I need function (probably it should be in AICompany) that change company colour (blue or yellow is better than pink :D ).
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
User avatar
Lord Aro
Tycoon
Tycoon
Posts: 2369
Joined: 25 Jun 2009 16:42
Location: Location, Location
Contact:

Re: Some API extension ideas

Post by Lord Aro »

yeah but what about multiple instances running?
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
Brumi
President
President
Posts: 921
Joined: 18 Jul 2009 17:54

Re: Some API extension ideas

Post by Brumi »

Lord Aro wrote:yeah but what about multiple instances running?
The function would simply return false then. It's similar to company names.
User avatar
Dustin
Transport Coordinator
Transport Coordinator
Posts: 272
Joined: 07 Dec 2005 19:22

Re: Not Very Important but I need it

Post by Dustin »

Kogut wrote:I need function (probably it should be in AICompany) that change company colour (blue or yellow is better than pink :D ).
I think this would be nice. Yellow contrasts very nicely with the generally green color of the game. So it's nice for screenshots. It would be nice to be able to set the color and president details and even have a code for keeping the same face.
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 13 Jul 2008 00:57
Contact:

Re: Not Very Important but I need it

Post by Michiel »

Dustin wrote:I think this would be nice. Yellow contrasts very nicely with the generally green color of the game. So it's nice for screenshots.
I agree, but I "solve" it by hitting reload until the desired colour comes up :)
svetovoi
Engineer
Engineer
Posts: 87
Joined: 12 Oct 2007 14:07

Re: Some API extension ideas

Post by svetovoi »

Dustin wrote:It would be nice to be able to set the color and president details and even have a code for keeping the same face
And the top of it - portraits/logo import, but, seems, it will be hardly possible.
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: Some API extension ideas

Post by Roujin »

Okay, maybe it has already been discussed (and rejected? I hope not :/), but I'd really like to have some trigonometric functions.
Sin, cos, tan and their inverses...

Or is there already a library with that?
I can probably live with a rather crude table (say 5° steps) look up... :roll:


If you're wondering what I need that for, my wip AI aims to create nice-looking networks, and I found that I need those functions for the decision where in a town to place the station, so it looks naturally in the end.

(here's a screen of a map where I ran some functions to find a possible network, along with comments to myself on how to go on designing my AI :lol: )
WolfAI teaser.png
(287.96 KiB) Downloaded 43 times
EDIT: could it be that those are already included in squirrel? I feel kinda dumb... :(
Last edited by Roujin on 09 Sep 2009 17:59, edited 2 times in total.
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
Chruker
Engineer
Engineer
Posts: 49
Joined: 01 Jun 2009 20:13

Re: Some API extension ideas

Post by Chruker »

Roujin wrote:EDIT: could it be that those are already included in squirrel? I feel kinda dumb... :(
Nope they are not included. It doesnt even have a function for getting square roots. However in regards to the square root function other AIs have their own, so I guess you could search the net for some fancy replacement functions.

Please let us know what if you find anything.
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Re: Some API extension ideas

Post by Rubidium »

Roujin wrote:Okay, maybe it has already been discussed (and rejected? I hope not :/), but I'd really like to have some trigonometric functions.
Sin, cos, tan and their inverses...
A simple search would have found topics discussing the exact same idea.
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: Some API extension ideas

Post by Roujin »

Alright, I'm officially too stupid to search.
Sorry for wasting your time on irc, TrueBrain.
Thanks for your help Chruker and Rubidium.

I somehow don't feel motivated to continue on my AI right now though.
Getting banned like that from the irc channel hurt me.
Maybe I'm just too sensitive for this community. :(
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
Chruker
Engineer
Engineer
Posts: 49
Joined: 01 Jun 2009 20:13

Re: Some API extension ideas

Post by Chruker »

Roujin wrote:I somehow don't feel motivated to continue on my AI right now though.
Getting banned like that from the irc channel hurt me.
Maybe I'm just too sensitive for this community. :(
Join #openttd.noai - the channel where TB doesnt roam :-)
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: Some API extension ideas

Post by Roujin »

Ok guys, I think the matter is more or less settled now.

The problem was probably me assuming that TrueBrain knew the answer to my question, and was just being unhelpful. That was obviously wrong. I was wrong. Sorry.
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
Blustuff
Engineer
Engineer
Posts: 112
Joined: 21 Aug 2008 09:37
Location: France

Re: Some API extension ideas

Post by Blustuff »

Roujin wrote:The problem was probably me assuming that TrueBrain knew the answer to my question, and was just being unhelpful. That was obviously wrong. I was wrong. Sorry.
I hardly believe he doesn't know. However, I still don't understand why there is no mathematical function. It isn't a matter of speed and I think Yexo told us "your AI don't need such functions". Actually they do.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Some API extension ideas

Post by Yexo »

There already is an implementation in squirrel you can use: http://www.tt-forums.net/viewtopic.php?p=777696#p777696
Blustuff wrote:It isn't a matter of speed and I think Yexo told us "your AI don't need such functions". Actually they do.
I did say that and was wrong. That doesn't mean I'll include those functions in the API. A main reason against including those in the API still is that they are floating point calculations, which OpenTTD tries to avoid as much as possible (because the results are not guaranteed to be the same on each platform). The existing squirrel support for floating point numbers can't be removed because it's used by too many AIs, but that doesn't mean we should add more floating point functions.
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 2 guests