[NoAI] For AI Writers - ET_VEHICLE_OLD Discussion

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

When do think/want the event ET_VEHICLE_OLD be triggered

One year before lifetime
1
25%
At lifetime
2
50%
One year (or more) after lifetime
0
No votes
Send it every year and let me choose when it's the best time !
1
25%
 
Total votes: 4

Muxyy
Engineer
Engineer
Posts: 15
Joined: 24 May 2011 16:59
Contact:

[NoAI] For AI Writers - ET_VEHICLE_OLD Discussion

Post by Muxyy »

Hello,

Some time ago, Krinn, who is the conceptor of DictatorAI (http://www.tt-forums.net/viewtopic.php?f=65&t=52982) made the request for a new event : ET_VEHICLE_OLD (http://bugs.openttd.org/task/5078).

This Event will permit to avoid looping on all vehicle in order to check the age and renew it if it's too old.

I made a first patch in order to provide this event.

In this first release of this patch, the event is triggered each time OpenTTD triggers a "vehicle is old" (triggered 1 year before lifetime), "vehicle is very old" (triggered at lifetime), and 'vehicle is very old and need to be replaced" (triggered each year after lifetime).

According to Yexo, something better must be found in order to trigger this event only once. It appears to me that the event triggered at lifetime should be the best moment.

And You, as conceptor of AI Script, when do you think it's the best way to send this event to your script ?

When replying, you can also link to your AI topic (if any).

You can also use the poll !

Thank you for your participation.
Last edited by Muxyy on 26 Aug 2012 17:19, edited 1 time in total.
OpenTTD France - http://www.openttd.fr
User avatar
Lord Aro
Tycoon
Tycoon
Posts: 2369
Joined: 25 Jun 2009 16:42
Location: Location, Location
Contact:

Re: [NoAI] For AI Writers - ET_VEHICLE_OLD Discussion

Post by Lord Aro »

What's wrong with having all 3?

ET_VEHICLE_OLD
ET_VEHICLE_VERY_OLD
ET_VEHICLE_VERY_VERY_OLD - maybe not this one though :L
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
Muxyy
Engineer
Engineer
Posts: 15
Joined: 24 May 2011 16:59
Contact:

Re: [NoAI] For AI Writers - ET_VEHICLE_OLD Discussion

Post by Muxyy »

Why an AI would need 3 events nearly the sames, posted 1 year before lifetime, at lifetime and 1 year or more after lifetime ?

If your AI is competitive, then the best is to renew as soon as possible, so at first time the framework will trigger the event.

If your AI is lazy (or stupid ?), then dont use this event, and let the vehicles outdated.
OpenTTD France - http://www.openttd.fr
Muxyy
Engineer
Engineer
Posts: 15
Joined: 24 May 2011 16:59
Contact:

Re: [NoAI] For AI Writers - ET_VEHICLE_OLD Discussion

Post by Muxyy »

Muxyy wrote:If your AI is competitive, then the best is to renew as soon as possible, so at first time the framework will trigger the event.
Another option would be to send this event every year, from begining with parameter indicating remaining year until lifetime. In that way you can replace vehicle when you want.
OpenTTD France - http://www.openttd.fr
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4765
Joined: 09 Sep 2007 05:03
Location: home

Re: [NoAI] For AI Writers - ET_VEHICLE_OLD Discussion

Post by Alberth »

That is beyond what the player currently gets, and thus not allowed.
Brumi
President
President
Posts: 921
Joined: 18 Jul 2009 17:54

Re: [NoAI] For AI Writers - ET_VEHICLE_OLD Discussion

Post by Brumi »

Maybe another solution would be to make this configurable by the AI, for example using some AIController::SetYearsBeforeAgingEvent(years) function.

Although I also think that an event like this would be a good idea, polling the vehicles is not that bad after all. SimpleAI polls the vehicles at the start of every year, and it's quite enough.

EDIT: Alberth posted while I was writing this. Responding to that, I think if we want to stick with getting the same information as the player, then Lord Aro's suggestion would be the most realistic.
Muxyy
Engineer
Engineer
Posts: 15
Joined: 24 May 2011 16:59
Contact:

Re: [NoAI] For AI Writers - ET_VEHICLE_OLD Discussion

Post by Muxyy »

After some talking with TrueBrain on IRC, i think that only one event is not enough.

When the event is triggered, the AI will be able to replace the vehicle with some conditions. Money is one fo those. If a new vehicle cant be bought, then it's useless to send the vehicle to the depot.

This vehicle has to wait for the next year for the event to be triggered again.

As said by Alberth, the first event must be triggered like in normal game : lifetime - 1 year, then every year until it will be replaced.

Last question : is it usefull to have a event parameter who indicates the replacement age in year (age - lifetime) ?
OpenTTD France - http://www.openttd.fr
User avatar
Hyronymus
Tycoon
Tycoon
Posts: 13235
Joined: 03 Dec 2002 10:36
Location: The Netherlands
Contact:

Re: [NoAI] For AI Writers - ET_VEHICLE_OLD Discussion

Post by Hyronymus »

Muxyy wrote:Last question : is it usefull to have a event parameter who indicates the replacement age in year (age - lifetime) ?
You mean a player-specified value of the age on which to replace rolling stock. I.e., specifying 5 means you get the reports from an age of 4 years (5-1) onward.
Muxyy
Engineer
Engineer
Posts: 15
Joined: 24 May 2011 16:59
Contact:

Re: [NoAI] For AI Writers - ET_VEHICLE_OLD Discussion

Post by Muxyy »

Hyronymus wrote:
Muxyy wrote:Last question : is it usefull to have a event parameter who indicates the replacement age in year (age - lifetime) ?
You mean a player-specified value of the age on which to replace rolling stock. I.e., specifying 5 means you get the reports from an age of 4 years (5-1) onward.
Replacement age (in year) = vehicle age (in year ) - lifetime (in year).

When receiving the first ET_VEHICLE_OLD, parameter will have value : -1. Lifetime will be reached in 1 year

Second event : value 0. Lifetime has been reached.

Next events : 1, 2, 4. Lifetime has been reached n years ago. Time to spare some money for replacement
OpenTTD France - http://www.openttd.fr
krinn
Transport Coordinator
Transport Coordinator
Posts: 342
Joined: 29 Dec 2010 19:36

Re: [NoAI] For AI Writers - ET_VEHICLE_OLD Discussion

Post by krinn »

I think we should get it once a year after the vehicle has reach lifetime -1 age. Like a human player get.
We don't really need any parameter, as an AI could just don't care about the information at all, if the vehicle is old enough to candidate for replacement, i might just don't care about its age and try to replace it.

And if we care about its lifetime remain or age, the API can gave us that if need, as soon as the AI get the event, the AI can take deeper look at vehicle info to take a final decision.
So save some extra cpu cycle and drop the parameter and let AI itself take that cpu cycle cost if it need.
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: [NoAI] For AI Writers - ET_VEHICLE_OLD Discussion

Post by Kogut »

IMHO - at the same time as it is presented to human player, to limit confusion.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
User avatar
MinchinWeb
Traffic Manager
Traffic Manager
Posts: 225
Joined: 01 Feb 2011 12:41
Contact:

Re: [NoAI] For AI Writers - ET_VEHICLE_OLD Discussion

Post by MinchinWeb »

Kogut wrote:IMHO - at the same time as it is presented to human player, to limit confusion.
I'll second that.
Alberta Town Names - 1500+ real names from 'Acme' to 'Zama City'
MinchinWeb's Random Town Name Generator - providing 2 million plus names...
WmDOT v13 - An AI that doubles as your highway department
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 15 guests