AI and autorenew?

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
User avatar
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

AI and autorenew?

Post by Bilbo »

Does AI have access to setting autorenew options for its company?

The option whether autorenew or not, and the options for min money and min. age of vehicle. While AI can periodically watch vehicle list and just send old vehicles to depot so they can get cloned and scrapped quite easily, the renew is better, as renewed vehicle keeps its current cargo and history of profits. Also, it means less code in the AI :)

AIController have only GetSetting, but no SetSettings... while most client-side settings do not make sense for AI (like whether something is shown in toolbar or not), the autorenew settings does make sense.
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: AI and autorenew?

Post by Yexo »

Yes, the functions you want are in AICompany. Note the AIController::GetSetting returns an AI setting, not a game setting. Those can be queried by AIGameSetting
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: AI and autorenew?

Post by Morloth »

I actually encountered quite a few problems with using the auto renew option in AIs:

- In the case of ships then a ship needs to be auto renewed and get the order to go to the nearest depot it might get lost because there are no depots in the neighbourhood.
- When a vehicle becomes obsolete it can't be autoreplaced with the same vehicle and thus never will.

I know in-game you have options to select 'replace vehicle X with vehicle Y', but I don't think these are available to AIs at the moment. Even then, the first problem will still exist.

What I've done now, is to have an order list like this:

1: Load / Unload Cargo
2: Move to some waypoint / or service in depot when needed, etc.
3: Load / Unload Cargo
4: If age >= max age goto 6
5: goto 1
6: Go to depot and stop

Then every now and then check all vehicle in depots and if they're over age do a replace function otherwise just sell them.

That should do the trick and solve all problems :).
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: AI and autorenew?

Post by Yexo »

Morloth wrote:- In the case of ships then a ship needs to be auto renewed and get the order to go to the nearest depot it might get lost because there are no depots in the neighbourhood.
- When a vehicle becomes obsolete it can't be autoreplaced with the same vehicle and thus never will.
The first is a problem also for human players, not with the NoAI code. The second is intended.
I know in-game you have options to select 'replace vehicle X with vehicle Y', but I don't think these are available to AIs at the moment. Even then, the first problem will still exist.
They are available in AIGroup.
User avatar
fanioz
Transport Coordinator
Transport Coordinator
Posts: 320
Joined: 19 Dec 2008 05:03
Location: Indonesia
Contact:

Re: AI and autorenew?

Post by fanioz »

Yexo wrote:
Morloth wrote:- In the case of ships then a ship needs to be auto renewed and get the order to go to the nearest depot it might get lost because there are no depots in the neighbourhood.
- When a vehicle becomes obsolete it can't be autoreplaced with the same vehicle and thus never will.
The first is a problem also for human players, not with the NoAI code. The second is intended.
I know in-game you have options to select 'replace vehicle X with vehicle Y', but I don't think these are available to AIs at the moment. Even then, the first problem will still exist.
They are available in AIGroup.
I've ever tried using AIGroup functions, it can autoreplace vehicles only if the new engine(vehicle) can goto station/depot order same as the old vehicle one. (the error said something like "Auto replace failed, the new vehicle can't goto one of your destination order")
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: AI and autorenew?

Post by Yexo »

fanioz wrote:I've ever tried using AIGroup functions, it can autoreplace vehicles only if the new engine(vehicle) can goto station/depot order same as the old vehicle one. (the error said something like "Auto replace failed, the new vehicle can't goto one of your destination order")
Am I right when you're saying you can't replace normal rail trains with monorail trains? That's intended, it's the same as for humans.
User avatar
fanioz
Transport Coordinator
Transport Coordinator
Posts: 320
Joined: 19 Dec 2008 05:03
Location: Indonesia
Contact:

Re: AI and autorenew?

Post by fanioz »

Yexo wrote:Am I right when you're saying you can't replace normal rail trains with monorail trains?
Similiarly :D , it happened with road vehicle. The new engine is articulated, the road station is not a drive-thru, thus it can't go there, and autoreplace would failed.
And u're right :
Yexo wrote: That's intended, it's the same as for humans.
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: Bing [Bot] and 17 guests