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
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5601
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: trAIns: An AI that plays only with trains

Post by PikkaBird »

petert wrote:Unfortunately, that error message is of little use to Ihrios
Perhaps you could let lhrios comment on whether he finds it useful himself? :roll:
lhrios
Engineer
Engineer
Posts: 22
Joined: 28 Dec 2008 00:16

Re: trAIns: An AI that plays only with trains

Post by lhrios »

Felix Atagong wrote: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
Bigger screenshot with the beginning of the errors attached as well...
Sorry for the long time to replay. I believe I have already correct this bug in newest version of trAIns (that I haven't published yet). If the problem persist, please send me a full screenshot with the line numbers.

Regarding the problem of predicting the railroad cost, as Zuu explained, it is really difficult. The best solution for trAIns is to estimate the cost after the planning. This does not solve the problem but at least avoids part of the needless expenses.

Thank you for sending suggestions.
Moriarty
Tycoon
Tycoon
Posts: 1395
Joined: 12 Jun 2004 00:37
Location: United Kingdom of Great Britain and Northern Ireland
Contact:

Re: trAIns: An AI that plays only with trains

Post by Moriarty »

I've just started a game and have the trAIns AI running. Using realistic acceleration and the American renewal trainset.
The problem is, the AI has built a nice coal route (and it is nice with a couple of quirks - nicely done), but the train it has built is completely unsuited to the task in that it can't climb a simple 2-cell-high hill. It slows to 1kph, though I'd swear it's slower.

The train has a tractive effort of 30kN and 450hp (4-4-0 American (Steam) type. The train has 144 tons of cargo capacity. I have the "freight multiplier" set to 4 (which I think is close to realistic). If it's 1, the train can make the hill.

Short version: The AI doesn't seem to take into account the freight multiplier when building trains.
Absolutis
Transport Coordinator
Transport Coordinator
Posts: 356
Joined: 16 Oct 2009 17:39

Re: trAIns: An AI that plays only with trains

Post by Absolutis »

I have a problem with this AI. I use 2cc trainset and UKRS. Realistic acceleration. 1.0.0 Beta2 Mac 10.5 PPC
See attachment (Under those black lines is /Users/My user folder.)
trAIns has not started yet. (Well, it built stations and before building trains, this.)
Attachments
Yeah, the error.
Yeah, the error.
ImageImage
lhrios
Engineer
Engineer
Posts: 22
Joined: 28 Dec 2008 00:16

Re: trAIns: An AI that plays only with trains

Post by lhrios »

Absolutis wrote:I have a problem with this AI. I use 2cc trainset and UKRS. Realistic acceleration. 1.0.0 Beta2 Mac 10.5 PPC
See attachment (Under those black lines is /Users/My user folder.)
trAIns has not started yet. (Well, it built stations and before building trains, this.)
Sorry, but trAIns is only compatible with default train set. Some API functions are necessary to create a version that can play with 2CC or NARS. For example, there is no way to test (before buying the locomotive and the wagon) if a locomotive can pull a specific wagon. There are locomotives (Maglev in NARS, for example) can pull only "x" wagons. However, the API does not provide a way to gather this information. Some AIs are partially compatible adopting a "trial and error" strategy.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: trAIns: An AI that plays only with trains

Post by Yexo »

lhrios wrote:Sorry, but trAIns is only compatible with default train set. Some API functions are necessary to create a version that can play with 2CC or NARS. For example, there is no way to test (before buying the locomotive and the wagon) if a locomotive can pull a specific wagon. There are locomotives (Maglev in NARS, for example) can pull only "x" wagons. However, the API does not provide a way to gather this information. Some AIs are partially compatible adopting a "trial and error" strategy.
The API doesn't provide this information because it can't provide it. That logic is coded in the newgrf files and even OpenTTD only knows that it can't attach the wagons at the moment you try it.
lhrios
Engineer
Engineer
Posts: 22
Joined: 28 Dec 2008 00:16

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

Post by lhrios »

This is the new version (v2) of trAIns. The full list of features can be found here. It needs to be tested more before be submitted to Bananas.
Attachments
trAIns.tar
(400 KiB) Downloaded 213 times
petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

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

Post by petert »

lhrios wrote:This is the new version (v2) of trAIns. The full list of features can be found here. It needs to be tested more before be submitted to Bananas.
On your page, it says "trAIns - An AI for OpenTDD" ;-)
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

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

Post by SirkoZ »

lhrios wrote:This is the new version (v2) of trAIns. The full list of features can be found here. It needs to be tested more before be submitted to Bananas.
The good:
Builds nice double lines all over the map, achieves high scores across the board. Those concentrated lines are nice with path-signal intersections.

Issues:
1.)
trAIns still can't start with a "hard" loan, i.e. $200k or even $300k for that matter. Suggested solution - first make it build some small (1-train if needed)-lines to get starting money, later the AI can delete these and start building its usual double lines (which are nice but require huge starting capital which the AI doesn't have).

2.)
trAIns doesn't upgrade bridges to newer/faster ones when they are available/when upgrading the rails.

3.)
trAIns spends so much time for looping/new connections (when there can hardly be built anything new) that it "doesn't have the time" to test for stations with 60 or less % transported, therefore it gets competition at those industries and/or such industries decrease production.

4.)
Signals on its double rails are too far (gaps too long) or not far enough apart (mostly on diagonal tracks).
Too far apart if looking from the point of view that a train has to wait the whole train-length before it can proceed down the line (especially when encountering Issue 5.)).
Not far enough apart - when Issue 5.) happens - i.e. trains wait to get to unloading station - because signals aren't one train-length apart, one train while reversing (if waiting too long) occupies two signal gaps instead of one.

5.)
Unloading stations are too small (only two lanes) for 23 to 50 trains that come to unload their cargo from multiple source industries to one factory/power station.

6.)
trAIns doesn't transport secondary/tertiary cargo, e.g. steel, goods. Although - this one didn't bother me - more for me to transport, but still, worth mentioning...
Steffl
Engineer
Engineer
Posts: 103
Joined: 23 Feb 2010 15:44

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

Post by Steffl »

Hi together.

Today the TrAIns AI crashed, when I was doing some testing with other AI's.
I think that it could not build a depot on the marked place in my screenshot and then crashed.
I played with the old version (v1) and Openttd 1.0 RC1.

Ok, hope you understand me and this report is helpful to you. Bye
Attachments
Brown & Co., 8. Nov 1949.png
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

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

Post by Kogut »

bug during upgrading railway (RV on crossing?)
Attachments
Przechwytywanie.PNG
Przechwytywanie.PNG (77.61 KiB) Viewed 5711 times
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
lhrios
Engineer
Engineer
Posts: 22
Joined: 28 Dec 2008 00:16

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

Post by lhrios »

Probably, what version was you using? If there was a vehicle in the road when it tries convert the track this will happen.
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

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

Post by Kogut »

From bananas / r19371
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Steffl
Engineer
Engineer
Posts: 103
Joined: 23 Feb 2010 15:44

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

Post by Steffl »

Hi, I found a little bug which let your AI crash.

I think the following code is false.

in railroad_manager.nut in line 768 & 778:

if(AIError.GetLastErrorString() == AIError.ERR_NOT_ENOUGH_CASH){

instead you should have written:

if(AIError.GetLastError() == AIError.ERR_NOT_ENOUGH_CASH){

GetLastErrorString is only for writing in the log and doesn't work here.

Bye.
Attachments
Black & Co., 4. Feb 1957.png
lhrios
Engineer
Engineer
Posts: 22
Joined: 28 Dec 2008 00:16

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

Post by lhrios »

Steffl wrote:Hi, I found a little bug which let your AI crash.

I think the following code is false.

in railroad_manager.nut in line 768 & 778:

if(AIError.GetLastErrorString() == AIError.ERR_NOT_ENOUGH_CASH){

instead you should have written:

if(AIError.GetLastError() == AIError.ERR_NOT_ENOUGH_CASH){

GetLastErrorString is only for writing in the log and doesn't work here.

Bye.
You are right. I will fix it as soon as possible.
Steffl
Engineer
Engineer
Posts: 103
Joined: 23 Feb 2010 15:44

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

Post by Steffl »

Wow, you're a fast man.
In so many lines of code there is always a place for some little bugs to hide .:-)
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

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

Post by planetmaker »

A small comment dedicated to this AI as based from my (short) competitive run with a number of other AIs: you you did very well!

Best areas of improvements now seem to be from this brief test: maybe you can try to add some air money maker in order to get fast(er) money for building more train routes? Due to a not very high income it'd be interesting to see whether the AI actually can build train networks... that'd be interesting to see :-)

Attached a screenshot which compares this AI with the best AI (AIAI) and the best train-using AI (simpleAI)

All in all: kudos, you did a great job :-)
Attachments
trAIns.png
lhrios
Engineer
Engineer
Posts: 22
Joined: 28 Dec 2008 00:16

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

Post by lhrios »

planetmaker wrote:A small comment dedicated to this AI as based from my (short) competitive run with a number of other AIs: you you did very well!
Thank you! =) The feedback is very important for us.
planetmaker wrote:Due to a not very high income it'd be interesting to see whether the AI actually can build train networks... that'd be interesting to see :-)
trAIns performance strongly depends on the scenario used. If the scenario has lot of water and an irregular landscape the path-finding will slow down and its performance will be negative affected. Regarding the networks, trAIns always tries to create them if "interesting" industries are near each other. If you want to see them, please try to run a test using a relative flat landscape with a high initial loan available.
User avatar
Lord Aro
Tycoon
Tycoon
Posts: 2369
Joined: 25 Jun 2009 16:42
Location: Location, Location
Contact:

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

Post by Lord Aro »

suggestion:
trains tunnelsmaybe.png
maybe you should let the ai build tunnels?
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
Timmaexx
Transport Coordinator
Transport Coordinator
Posts: 301
Joined: 03 Jan 2009 17:55

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

Post by Timmaexx »

Wouldn't such a tunnel bankrupt the company?
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 7 guests