trAIns: An AI that plays only with trains (v2)

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

User avatar
cmoiromain
Chief Executive
Chief Executive
Posts: 655
Joined: 15 Jan 2007 21:45
Location: FRANCE
Contact:

Re: trAIns: An AI that play only with trains

Post by cmoiromain »

Actually, one more thing.

A couple of minutes later, the AI decided to link that second coal mine that was right next to an already existing station (see screenshot n°6). Here is what it did:
weird7.png
(171.66 KiB) Downloaded 66 times
Why didn't it link directly to the already existing line? The line it built instead is very strange; it uses bridges to go over town roads instead of going around them, and it goes over already existing track to link to the same main line immediately afterwards. Moreover, as I already pointed out, it would have been more clever to link to the mainline closer to the destination (ie at the bottom of the screen) than further away.

EDIT:

There seems to be a lot of places where the AI could have reused existing track and doesn't. I think what causes that is that the AI choses where it will connect the line and then tries to figure out how to connect the two places. This results in strange behaviours sometimes.
weird8.png
(428.9 KiB) Downloaded 57 times
The AI tried to link the green line to the place circled in blue. Something went wrong obviously, because it stopped building during the process. I could have linked it to the place circled in red (it seems more logic to me...).

Also, it seems that the AI doesn't like to use the same rail for two different cargos. At some places on the map there are for or six tracks instead of two, simply because it transports two or three different cargos, despite them traveling roughly the same route.

I will post the savegame once I think the game is over.

On a side note, is an option for trains to drive on the right a possibility?
I am little, ugly, and nasty. How do you do?

lhrios
Engineer
Engineer
Posts: 22
Joined: 28 Dec 2008 00:16

Re: trAIns: An AI that play only with trains

Post by lhrios »

cmoiromain wrote:Hi

First of all, I really love your AI. Other train building AIs are nice, but none have the building style which I like to see in my games.

I just decided to run a game with only trAIns, nothing else, to see how it goes. Immediately it started to build pretty networks all over the map.
Thanks!
cmoiromain wrote: Here are a few remarks I want to point out, to make the pathfinding even better.
weird1.png
Here, I think the AI is trying to link the coal mine at the bottom left to the power plant at the top. IMO it should instead link the coal mine to the power plant that is at the end of the line that disappears at the bottom of the screen (as it did with the other three coal mines already linked to is).
This happens because the distance between the coal mine and the power station is too long. So, it can not connect the industries. I can extend this limit but things like that will always exist.
cmoiromain wrote:
weird2.png
This is a closeup on where the three lines merge. I think some improvement can be made there. The bottom one could have this tight turn removed, and the top one could have been replaced by a straight line, connecting to the main line closer to where the bottom one links.
This is complicated because it needs to know the junction point before it can compute the path. It just knows that the junction point is not the better after compute the path.
cmoiromain wrote:
weird3.png
I think those bridges are unnecessary, it would be better tu go arround the lake rather than over it. OTOH, I don't know which of the two is cheaper.

More on the following post.
There is a trade off between good railways (straight lined) and computing the path fast. I chose to compute the path fast instead of create always straight lined paths. Is also expensive try to avoid bridges.

lhrios
Engineer
Engineer
Posts: 22
Joined: 28 Dec 2008 00:16

Re: trAIns: An AI that play only with trains

Post by lhrios »

cmoiromain wrote:Actually, one more thing.

A couple of minutes later, the AI decided to link that second coal mine that was right next to an already existing station (see screenshot n°6). Here is what it did:
weird7.png
Why didn't it link directly to the already existing line? The line it built instead is very strange; it uses bridges to go over town roads instead of going around them, and it goes over already existing track to link to the same main line immediately afterwards. Moreover, as I already pointed out, it would have been more clever to link to the mainline closer to the destination (ie at the bottom of the screen) than further away.

EDIT:

There seems to be a lot of places where the AI could have reused existing track and doesn't. I think what causes that is that the AI choses where it will connect the line and then tries to figure out how to connect the two places. This results in strange behaviours sometimes.
weird8.png
The AI tried to link the green line to the place circled in blue. Something went wrong obviously, because it stopped building during the process. I could have linked it to the place circled in red (it seems more logic to me...).

Also, it seems that the AI doesn't like to use the same rail for two different cargos. At some places on the map there are for or six tracks instead of two, simply because it transports two or three different cargos, despite them traveling roughly the same route.

I will post the savegame once I think the game is over.

On a side note, is an option for trains to drive on the right a possibility?
This really needs to be fixed!

User avatar
cmoiromain
Chief Executive
Chief Executive
Posts: 655
Joined: 15 Jan 2007 21:45
Location: FRANCE
Contact:

Re: trAIns: An AI that play only with trains

Post by cmoiromain »

Here is the end of the game. The AI didn't seem to build anymore.

Attached are a screenshot of the middle of the map at the end (year 1984, started in 1950), the statistics of the company, and the save (created with r17287).

If you scrollaround the map, you will find quite a few places where the track is built in a strange way. Also, in many cases, as I said before, there a duplicate tracks where it could have been one track for many trains.

Suggestions for later:

Enlarge stations (one power plant station became too crowded at one point, and two platforms wasn't enough).

Use already existing tracks more often, and then enlarge the main lines to 2*2 instead of 2*1 tracks. I don't know how complicated that would be... It would require to classify tracks as main line, secondary line etc...

Transport passengers, oil, mail, goods and valuables.

At farms, transport both grain and cows.

At factories, use only one drop off station for all cargos, and add platforms when needed.

Good luck with improving it. I look forward to the next release =)
Attachments
overall.png
(316.02 KiB) Downloaded 79 times
stats.png
(42.38 KiB) Downloaded 74 times
trAIns03.sav
(333.91 KiB) Downloaded 115 times
I am little, ugly, and nasty. How do you do?

Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: trAIns: An AI that play only with trains

Post by Roujin »

OT, but I think you've stumbled across a little bug in stats.png. The red Months in the "Operating profit graph" window. Care to file a bug report on bugs.openttd.org?
* @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

User avatar
cmoiromain
Chief Executive
Chief Executive
Posts: 655
Joined: 15 Jan 2007 21:45
Location: FRANCE
Contact:

Re: trAIns: An AI that play only with trains

Post by cmoiromain »

No, this is because my company was in the red (I switched it off from the graphs for the screenshots). The reason for this is that I just did the money cheat so I wouldn't go bankrupt, and just let the game go fast forward. Even with all the money reimbursed to the bank, there are some magic costs appearing from nowhere (taxes? =S ) that make me have negative profit.
I am little, ugly, and nasty. How do you do?

Wold
Transport Coordinator
Transport Coordinator
Posts: 318
Joined: 03 Aug 2006 19:32
Skype: woldy_bg
Location: Bulgaria

Re: trAIns: An AI that play only with trains

Post by Wold »

Not exactly checked :
Attachments
trains1.png
(49.32 KiB) Downloaded 90 times
Image

User avatar
cmoiromain
Chief Executive
Chief Executive
Posts: 655
Joined: 15 Jan 2007 21:45
Location: FRANCE
Contact:

Re: trAIns: An AI that play only with trains

Post by cmoiromain »

Isn't that caused by the lack of save/load implementation?
I am little, ugly, and nasty. How do you do?

SmatZ
OpenTTD Developer
OpenTTD Developer
Posts: 351
Joined: 03 Oct 2006 18:26
Location: Prague, Czech Republic
Contact:

Re: trAIns: An AI that play only with trains

Post by SmatZ »

Why isn't it available via BaNaNaS yet? :-)
Image

lhrios
Engineer
Engineer
Posts: 22
Joined: 28 Dec 2008 00:16

Re: trAIns: An AI that play only with trains

Post by lhrios »

SmatZ wrote:Why isn't it available via BaNaNaS yet? :-)
How can I do it?

Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: trAIns: An AI that play only with trains

Post by Roujin »

Via the web interface at content.openttd.org
Here's more information: http://wiki.openttd.org/Content_Service
* @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

User avatar
Menno
Tycoon
Tycoon
Posts: 1190
Joined: 05 Feb 2005 14:35
Location: Netherlands, Utrecht

Re: trAIns: An AI that plays only with trains

Post by Menno »

I tried a game with TrAIns v1 among other AI's.
It performed very good. It achieved high income, comp value & profit with relatively low cargo transported. Apart from that its tracks and networks look like I made them myself, straightforward and without refraining from using | and - pieces which other train-based AI's tend to do. There was one small glitch however:
I started it in 1977, when it began building trains with BR125 engines. After some 10 years, it decided to upgrade most (not all!) of these to TGV's, and put the BR125s all in depots for some 2 years, without upgrading. Then suddenly the stopped trains were all upgraded and running again. I was thinking it might have been a money problem, but as far as I have kept track of it, it shouldn't have been an issue as there were some 20 trains stopped, TGV cost only 90k GBP (20*90=1.8M) and it owned several millions of GBP at that moment.
See attached save game and screenshot.
OpenTTD 0.7.3
NewGRFs: OpenGFX, better vehicles names, Av8 1.501

(I will post comparable posts in the other AI's topics)

EDIT: btw I really like this AI :)
Attachments
AI game.sav
(658.84 KiB) Downloaded 91 times
replacing for tgvs.png
(277.53 KiB) Downloaded 1 time
*hmz*

lhrios
Engineer
Engineer
Posts: 22
Joined: 28 Dec 2008 00:16

Re: trAIns: An AI that plays only with trains

Post by lhrios »

Menno wrote:I tried a game with TrAIns v1 among other AI's.
It performed very good. It achieved high income, comp value & profit with relatively low cargo transported. Apart from that its tracks and networks look like I made them myself, straightforward and without refraining from using | and - pieces which other train-based AI's tend to do. There was one small glitch however:
I started it in 1977, when it began building trains with BR125 engines. After some 10 years, it decided to upgrade most (not all!) of these to TGV's, and put the BR125s all in depots for some 2 years, without upgrading. Then suddenly the stopped trains were all upgraded and running again. I was thinking it might have been a money problem, but as far as I have kept track of it, it shouldn't have been an issue as there were some 20 trains stopped, TGV cost only 90k GBP (20*90=1.8M) and it owned several millions of GBP at that moment.
See attached save game and screenshot.
OpenTTD 0.7.3
NewGRFs: OpenGFX, better vehicles names, Av8 1.501

(I will post comparable posts in the other AI's topics)

EDIT: btw I really like this AI :)
Thanks for trying trAIns. This problem will be fixed in next AI release.

User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1506
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: trAIns: An AI that plays only with trains

Post by SirkoZ »

Just a confirmation - I also observed delayed locomotive replacement.

I played a subtropic game with trAIns, some SimpleAI's and a NiceCAB (for ships and planes) and trAIns took a good half year to replace Wills 2-8-0's with the CS4000 although it did replace them. It's like it just falls asleep when all the trains are in depot and then after some rest suddenly awakens and gets back to work. :-)

Felix Atagong
Engineer
Engineer
Posts: 45
Joined: 16 Apr 2007 19:50
Location: Louvain
Contact:

Re: trAIns: An AI that plays only with trains

Post by Felix Atagong »

I start my games very early , using the horses from eGRTVS and the American trainset that has some simple trains starting from the 1830s, with an initial loan of 10,000 £ (5,900,000 BEF)...

After some computing TrAIns mostly builds 2 far-away stations and only checks afterwards if a path can be build between them. In most games this is not the case, but TrAIns start building rails and stations anyway. When it is found out that a closed track will never be realised all rails is deleted, so are the station with the result that from the initial loan there is only 10% left, enough to survive for another year or so, sometimes 2. After that TrAIns goes bankrupt. The screenshot shows that only 871,499 BEF has been recuperated from the 10,766,025 that was used for building the stations and rails.

Why don't TrAIns checks first if there is enough money before starting to build rails, stations (and then it still needs some money to buy a train), especially in the 1800's only small, rather short tracks are profitable...

Just a thought...
Attachments
Atagong Transport, 30 Sep 1851.png
Atagong Transport, 30 Sep 1851.png (15.55 KiB) Viewed 3081 times

User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4554
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: trAIns: An AI that plays only with trains

Post by Zuu »

It is quite hard to get an exact figure of how much it would cost, even if a path has been searched it is still not trivial to calculate the cost exactly. Before a path has been found it is even harder to make a good estimate of the cost.

So while I can agree that it would be good to check the cost it is a far from trivial task.

Though, I think most AI authors like to get some feedback so it is still nice of you to post your though. Doing some kind of cost estimation is not impossible, just not trivial.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

Felix Atagong
Engineer
Engineer
Posts: 45
Joined: 16 Apr 2007 19:50
Location: Louvain
Contact:

Re: trAIns: An AI that plays only with trains

Post by Felix Atagong »

A couple of posts I told how TrAIns will build stations even it if can't join them, and start building tracks even if it doesn't have enough money.
Same game, a couple of decades further and TrAIns manages to connect two stations and then...
Atagong Transport, 22 Aug 1868.png
Atagong Transport, 22 Aug 1868.png (3.22 KiB) Viewed 3033 times
Bigger screenshot with the beginning of the errors attached as well...
Attachments
Atagong Transport, 12 Aug 1868.png

petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: trAIns: An AI that plays only with trains

Post by petert »

Unfortunately, that error message is of little use to Ihrios because the line number where the error occured (the [xxx] at the end of each line) is not visible. Wait for another crash and catch the [xxx] line numbers.

User avatar
Lord Aro
Tycoon
Tycoon
Posts: 2366
Joined: 25 Jun 2009 16:42
Location: Location, Location
Contact:

Re: trAIns: An AI that plays only with trains

Post by Lord Aro »

telling him that is isn't that useful as it's fairly obvious that he's enlarged the AI debug window as large as he can anyway :roll:
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

User avatar
Gremnon
Tycoon
Tycoon
Posts: 1517
Joined: 16 Sep 2005 12:23
Skype: the_gremnon
Location: /home
Contact:

Re: trAIns: An AI that plays only with trains

Post by Gremnon »

It's possible to move even a window like that off the edge, in order to widen it enough to find out the last chunks of those errors, so yes, it is useful to know that.

A little common sense.

Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 2 guests