Improving the Trolly-AI

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
rfalke
Engineer
Engineer
Posts: 16
Joined: 06 Jan 2007 18:44

Improving the Trolly-AI

Post by rfalke »

Hello

We all know that the old (default) AI ist quite bad. And also doesn't
support MP. The new (trolly) supports MP but only buses and trucks.

I spend some time adding the trains feature to the trolly AI. This was
relative easy so far since trolly was already prepared for this step. (my thanks to TrueLight) I have named the improved "MPAI" for
Multiplayer AI.

While this is not finished yet I can say that it performs MUCH better than
the default AI on my testmap and also quite good in general.

I have attached a screenshot where you can see that he likes to build
rail roads.

Raimar
Attachments
mpai.png
(1.25 MiB) Downloaded 830 times
User avatar
Brianetta
Tycoon
Tycoon
Posts: 2567
Joined: 15 Oct 2003 22:00
Location: Jarrow, UK
Contact:

Post by Brianetta »

Still no junctions, though. Not even passing loops. Are these things to come to pass?
PGP fingerprint: E66A 9D58 AA10 E967 41A6 474E E41D 10AE 082C F3ED
rfalke
Engineer
Engineer
Posts: 16
Joined: 06 Jan 2007 18:44

Post by rfalke »

Brianetta wrote:Still no junctions, though. Not even passing loops. Are these things to come to pass?
I disabled junctions for now because adding signals is something
for a later stage.

Well I'm not a big fan of passing loops. But I plan to implement
RoRo stations.

Raimar
l_Blue_l
Transport Coordinator
Transport Coordinator
Posts: 285
Joined: 29 Mar 2006 22:42
Contact:

Post by l_Blue_l »

I have a couple of ideas that i have been implementing and they could be useful to you for improve the AI in the areas of helping with the choosing of if its a good idea or not to place a station at a given industry, Amount of Vehicles need to Transport the given goods (i have 3 ways i will be implementing this), and Relay Stations.

If you are interested in any of these please let me know.
rfalke
Engineer
Engineer
Posts: 16
Joined: 06 Jan 2007 18:44

Post by rfalke »

l_Blue_l wrote:I have a couple of ideas that i have been implementing and they could be useful to you for improve the AI in the areas of helping with the choosing of if its a good idea or not to place a station at a given industry, Amount of Vehicles need to Transport the given goods (i have 3 ways i will be implementing this), and Relay Stations.

If you are interested in any of these please let me know.
Sure I'm interested. This is indeed an area which needs improvements.
I think that there are two input parameters to this: the amount of
cargo to ship and the distance. And from this some code has to
decide how many tracks, trains and wagons.

Raimar
l_Blue_l
Transport Coordinator
Transport Coordinator
Posts: 285
Joined: 29 Mar 2006 22:42
Contact:

Post by l_Blue_l »

One thing that would help is knowing how many station are collecting stuff from the industry so 5 different station wont pop up at the same industry. 2 or 3 station(?) can work if the industry is producing enough and it is worth to try and steal it from the other companies.

Explaining the different system for the Amount of Vehicles need to Transport the given goods.

One which i am just starting to work on is a system where it auto builds vehicles so a given amount of vehicle are always waiting for full load at the starting station until a vehicle arrives back to the start.

The next one is sort of a monitoring system where it track the time it takes to get there and back and keep a record of it.

And finally one which i have given up on for the time being is an ETA system where it will tell you how long it will take you train to get there and back. (as it will send the vehicle the full journey of the trip all at once (not sure if the devs would like this)) (this system wouldn't be to hard to implement for a network with no trains(or vehicles on it) as i have already done to some extent but it can get very painfully if there are trains or vehicles.
rfalke
Engineer
Engineer
Posts: 16
Joined: 06 Jan 2007 18:44

Post by rfalke »

l_Blue_l wrote:One thing that would help is knowing how many station are collecting stuff from the industry so 5 different station wont pop up at the same industry. 2 or 3 station(?) can work if the industry is producing enough and it is worth to try and steal it from the other companies.
I plan to this. So that max_cargo=production-of-industry/number-of-stations
and than depending on max_cargo it id decided if a route is build at all and how big.
l_Blue_l wrote:Explaining the different system for the Amount of Vehicles need to Transport the given goods.
I do not understand.
l_Blue_l wrote:One which i am just starting to work on is a system where it auto builds vehicles so a given amount of vehicle are always waiting for full load at the starting station until a vehicle arrives back to the start.
Yes something like this. But it only works good with buses, trucks and a circular rail design. Dedicated tracks without passing loops are easy to
construct but will only support one train.
l_Blue_l wrote:The next one is sort of a monitoring system where it track the time it takes to get there and back and keep a record of it.

And finally one which i have given up on for the time being is an ETA system where it will tell you how long it will take you train to get there and back. (as it will send the vehicle the full journey of the trip all at once (not sure if the devs would like this)) (this system wouldn't be to hard to implement for a network with no trains(or vehicles on it) as i have already done to some extent but it can get very painfully if there are trains or vehicles.
Yes from time to time routes need to be checked. Possible outcomes could be:
1) vehicles doesn't make profit: the code could try to find the reason (hard) or just sell everything. Possible reasons: destination doesn't accept the cargo any more, producer stoped producing, cargo output too low for the amount of vehicles,...
2) surplus cargo at the producer: add more vehicles
Tomsomethingcon
Engineer
Engineer
Posts: 123
Joined: 16 Nov 2006 16:52

Post by Tomsomethingcon »

is there any where we can download this "mod" so we can also try it ?
User avatar
Celestar
Director
Director
Posts: 574
Joined: 02 Jul 2004 10:56
Contact:

Post by Celestar »

Well that looks rather promising.

One thing to keep in mind is that an industry only supplies 2 stations (highest rating) with goods for the time being (might change later on). So the AI should look around an industry and if it finds that there are two reasonably high rating ones, it should not use that industry.

Are you planning to provide us with a diff at some point? ;)

Celestar
oVRoM
Engineer
Engineer
Posts: 37
Joined: 11 Jan 2003 10:40
Location: Utah

Post by oVRoM »

rfalke wrote:1) vehicles doesn't make profit: the code could try to find the reason (hard) or just sell everything. Possible reasons: destination doesn't accept the cargo any more, ...
Since for humans players a news message is generated about stations no longer accepting a certain type of cargo, couldn't something similar be done for the AI?
That way maybe it could check if it has a route depending on that station accepting that cargo type, and if so just delete the route.
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Post by SirkoZ »

Wow - rfalke - your patch looks really nice. Finally better rail management from Compu-titors. :D

The road AI has been very nice (with exception it didn't renew/upgrade (all of) its vehicles) already but rail really needs a major overhaul...
Perhaps even with 2 track lines (one in each direction).

For better ratings on all those stations you could also include a better station rating-compute patch - now there have been made at least 2 of them so far, but are buried in the past.
You can get the code from the SourceForge's OpenTTD patch list.
rfalke
Engineer
Engineer
Posts: 16
Joined: 06 Jan 2007 18:44

Post by rfalke »

Celestar wrote:Well that looks rather promising.

One thing to keep in mind is that an industry only supplies 2 stations (highest rating) with goods for the time being (might change later on). So the AI should look around an industry and if it finds that there are two reasonably high rating ones, it should not use that industry.

Are you planning to provide us with a diff at some point? ;)

Celestar
I have attached a snapshot. It is under development. You have
to disable road vehicles to make it work. Also currently I'm only
testing with a flat landscape so watch out for problems with
mountains. See the TODO for other things which do not work yet.

EDIT: start with "-d ai=9" to have something to read

Raimar
Attachments
mpai-snapshot-2007-01-16.diff.gz
(20.19 KiB) Downloaded 259 times
rfalke
Engineer
Engineer
Posts: 16
Joined: 06 Jan 2007 18:44

Post by rfalke »

rfalke wrote:
Celestar wrote:Well that looks rather promising.

One thing to keep in mind is that an industry only supplies 2 stations (highest rating) with goods for the time being (might change later on). So the AI should look around an industry and if it finds that there are two reasonably high rating ones, it should not use that industry.

Are you planning to provide us with a diff at some point? ;)

Celestar
I have attached a snapshot. It is under development. You have
to disable road vehicles to make it work. Also currently I'm only
testing with a flat landscape so watch out for problems with
mountains. See the TODO for other things which do not work yet.

EDIT: start with "-d ai=9" to have something to read

Raimar
There is a new snapshot with a lot of improvements:
- make buses and trucks work again
- support upgrade rails and trains
- select industry source by amount and number of stations
- much better loan management
- fix handling of crashed vehicles
- better debug methods
- and a lot of other improvements

It now runs on my test map without a problem from 1950 to 2050.
And the top AI player achieves 270mio at the end.

The next things on the todo list are:
- upgrade bridges
- passanger trains
- roro stations
- test multiplayer

Please try the patch and report both success and failure. Run
with "-d ai=2" to get some output.

Raimar
Attachments
mpai-snapshot-2007-02-08.diff.gz
(41.65 KiB) Downloaded 250 times
User avatar
Celestar
Director
Director
Posts: 574
Joined: 02 Jul 2004 10:56
Contact:

Post by Celestar »

I'll try this out in the next few days...

Celestar
User avatar
Villem
Tycoon
Tycoon
Posts: 3310
Joined: 28 Aug 2003 09:38

Post by Villem »

Could you possibly try make the AI try combining stations, so for example one AI player doesn't have 5 unloading stations around a power station, but rather just 1 wich it expands to accommodate new coal routes?
Last edited by Villem on 10 Feb 2007 17:07, edited 1 time in total.
rfalke
Engineer
Engineer
Posts: 16
Joined: 06 Jan 2007 18:44

Post by rfalke »

Akalamanaia wrote:Could you possibly try make the AI try combining stations, so for example one AI player doesn't have 5 unloading stations around a power station, but rather just 1 wich it expands to accomodate new coal routes?
Yes I can put it on the todo list.

Raimar
User avatar
Celestar
Director
Director
Posts: 574
Joined: 02 Jul 2004 10:56
Contact:

Post by Celestar »

The pathfinding appears to work rather nicely.

I noticed something about depots: Trains should have a "Service At" order instead of "Go To" for depots.

Celestar
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 21 guests