Terron AI

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

svetovoi
Engineer
Engineer
Posts: 87
Joined: 12 Oct 2007 14:07

Terron AI

Post by svetovoi » 21 May 2011 13:01

Hi guys,

I am glad to present my AI - Terron.

The goal was to make this AI as a strong, stable and earning player as I could.
The AI can use buses, trucks, planes, ships and has more or less flexible settings to adjust it to your needs.
I hope you will enjoy playing with it.

OpenTTD version requirement: 1.3.0 or higher. Actual AI version: 209.
Terron works with NewGRFs. At least with FIRS and those which add new vehicles: Aviators, eGRVTS, FISH, e.t.c.

Save/Load is supported, but because AI uses preprocessing a lot(to make things much faster later) it can require up to several game months for reinitialization and complete recovering. Be aware about it and do not abuse save/load, please.

Please let me know about bugs you find, preferably with AI Debug window screenshots or AI log, or ideally with saved game *before* AI crash, though the last one can be hard to obtain. General suggestions and feedback are welcomed too, of course.

That's pretty much all, but just in case if some people would like to see "features list" I scratched one:
  • Terron can use buses, trucks(mail included), planes and actually working ships.
    You already know that, but this is the very main "feature" by the way!
  • Roads reusing.
    Why to build own road if there is already one nearby?
    AI is regularly seeking and more than able to find and use roads built by other players. Wonderful!
  • Traffic control based on available infrastructure.
    AI will not build more vehicles for a station than it can handle.
    No longer planes in dozens will be flying around an airport desperately waiting for a chance to land, or endless trucks be staying in line near a lone truck stop. Instead increased rate of vehicles arrival achieved by accurate stations expansion. And stylish as well!
  • Cargo transferring.
    By combining airport/dock and bus stations, Terron can build versatile transfer system which provides stream of passengers, maintaining both smooth and profitable planes/ships work. Now with freight too. Splendid!
  • Advanced pathfinding.
    The custom road version of the popular A* comes in bidirectional implementation.
    This improved method allows not only extremely fast roads search and construction, but also requires significantly lesser time for understanding situations when road can't be built. With several work modes for different tasks and improved Fibonacci heap for increased speed, the custom A* is a must for today's AI!
  • Even more advanced pathfinding.
    Hierarchical A* for ships' paths search can connect two docks on the opposite sides of the map literally within seconds. Unbelievable!
  • Fast decision making.
    That's, you know, mighty Artificial Intilligence after all.
    When initial preprocessing - which isn't too long too - is done, Terron may choose what to do next with speed you'll never be able to. Tremendous!
  • Smart decision making.
    Terron weighs own actions as investment projects and chooses what to do next depending on the own company's current income and bank balance, as well as actions' cost and estimated profit. Brilliant!

    "Smart" mode now always on by default.
  • General kindness.
    When AI has no money or it has nothing to do, Terron generously falls sleep in humble attempt to save several precious microseconds of your processor's lifetime, or maybe make a game a bit more smooth. Remarkable!
Last edited by svetovoi on 19 Jun 2013 10:11, edited 6 times in total.

svetovoi
Engineer
Engineer
Posts: 87
Joined: 12 Oct 2007 14:07

Re: Terron AI

Post by svetovoi » 21 May 2011 13:01

Reserved for who knows what

Brumi
President
President
Posts: 904
Joined: 18 Jul 2009 17:54

Re: Terron AI

Post by Brumi » 22 May 2011 14:30

I am truly impressed. :D
I ran a short test with your AI against some others, and it's working well, no crash, being on par financially with the leading AIs. It's very mature for a first-release AI.
The only "bug" I can report so far is a typo in the settings window: "adanced" project assessment model.

Are you planning to add train support as well? I'm to see another multi-profile AI :)

svetovoi
Engineer
Engineer
Posts: 87
Joined: 12 Oct 2007 14:07

Re: Terron AI

Post by svetovoi » 22 May 2011 17:03

Thanks for feedback, I'm glad to hear that Terron has not crashed(yet :) ).

Now "adanced", heh, how could I look at it weeks and did not notice?

And trains... this is something kinda hard to make "right". You see, I don't want to make trains like just bigger trucks.
To connect two points on the map within small radius of 150 - 200 tiles and then select another pair and then one more and so on.
Not bad for trucks, but trains... there are some magic within, something what I wouldn't like to see being ruined by AI which spams endless mess of rail's spaghetti just because it can.
Long and straight main lines, rails reusing, sensible and rational network - that's what interesting. And hard.

Without really good and fast rail pathfinder this is just impossible.
During latest addition of ships to the Terron I made a fast HPA* to build buoys, but constructing two parallel rail lines in hills is not the same as placing a buoy at flat sea every 25 tiles.
Maybe it's already written in other AI? I checked several (Admiral, Otvi) but not very closely.
Path of length around 350 tiles within two - three game weeks would be fine performance.

User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9282
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Terron AI

Post by planetmaker » 22 May 2011 17:08

There are already a few AIs which handle trains. Most notably you might want to look at NoCAB, AIAI and then also AdmiralAI and possibly SimpeAI and ChooChoAI as well. Maybe they have already solved some issues of yours already you have with trains. They're - IIRC - all licensed under GPL v2, so re-using stuff should not be a problem, if you chose that license, too.

svetovoi
Engineer
Engineer
Posts: 87
Joined: 12 Oct 2007 14:07

Re: Terron AI

Post by svetovoi » 23 May 2011 14:13

Hmm, after checking several(5 to be accurate) AIs I decided to stick to the plan I had before and to separately test ideas of future trains' system with simpler transport types. Only NoCAB is fast enough, but there are something strange with the path it choose.

So its more likely that either some not trivial freight ships or trucks oriented on delivery of goods instead of coal will be my next step, not trains.

User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 313
Joined: 13 Jul 2008 00:57
Contact:

Re: Terron AI

Post by Michiel » 23 May 2011 15:00

ac84 wrote:And trains... this is something kinda hard to make "right". You see, I don't want to make trains like just bigger trucks.
To connect two points on the map within small radius of 150 - 200 tiles and then select another pair and then one more and so on.
Not bad for trucks, but trains... there are some magic within, something what I wouldn't like to see being ruined by AI which spams endless mess of rail's spaghetti just because it can.
Long and straight main lines, rails reusing, sensible and rational network - that's what interesting. And hard.
So true...

Maraxus
Engineer
Engineer
Posts: 2
Joined: 26 May 2011 17:56

Re: Terron AI

Post by Maraxus » 26 May 2011 18:28

First crash:
TerronCrash.png
(33.79 KiB) Downloaded 2 times
Happened shortly after loading this save:
TerronAI-test, 3rd Sep 1998.sav
(632.99 KiB) Downloaded 241 times
So far a very solid AI.

svetovoi
Engineer
Engineer
Posts: 87
Joined: 12 Oct 2007 14:07

Re: Terron AI

Post by svetovoi » 27 May 2011 15:00

Fixed.
I have also added couple of options in the settings screen and removed bottleneck in the AI's start period. There are also minor tweaks, not very important stuff.

New version in the first post, saves should be compatible (but who knows all).
If it doesn't contain new bugs I'll add AI to the content library at the weekend.

Brumi
President
President
Posts: 904
Joined: 18 Jul 2009 17:54

Re: Terron AI

Post by Brumi » 27 May 2011 16:15

I've loaded the savegame with the previous version with your AI, still no crash, it's doing well :)
There is a problem with its ships though, that little peninsula makes things hard for your pathfinder. Ships coming from the north are stuck.
ships.png
ships.png (81.88 KiB) Viewed 13253 times
There is a savegame in this post if you're interested how your AI is doing in my game.

User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9282
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Terron AI

Post by planetmaker » 27 May 2011 16:44

Brumi wrote:I've loaded the savegame with the previous version with your AI, still no crash, it's doing well :)
There is a problem with its ships though, that little peninsula makes things hard for your pathfinder. Ships coming from the north are stuck.
ships.png
There is a savegame in this post if you're interested how your AI is doing in my game.
Not a solution, but a work-around: Set the ship path finder also to YAPF.

svetovoi
Engineer
Engineer
Posts: 87
Joined: 12 Oct 2007 14:07

Re: Terron AI

Post by svetovoi » 27 May 2011 16:50

I'm using NPF and when ships stuck AI receives notification and sells all of them.
With NPF they stuck much lesser too.

Brumi
President
President
Posts: 904
Joined: 18 Jul 2009 17:54

Re: Terron AI

Post by Brumi » 28 May 2011 11:35

In my test game, Terron leaves quite a lot of deserted stations on the map. The vehicles were probably sold because of bad performance, but the stations were left behind. Is it intentional?

Anyway, in the detailed performance ratings, how is the number of stations calculated? Are only those stations calculated which have been visited in the past n months?

svetovoi
Engineer
Engineer
Posts: 87
Joined: 12 Oct 2007 14:07

Re: Terron AI

Post by svetovoi » 28 May 2011 14:05

Yes, AI should close shorter trade lines, those which usually was built first. Stations may be reused lately or may be not, it depends on particular situation.

Dunno about the second question, maybe http://wiki.openttd.org/OpenTTD will help you.

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

Re: Terron AI

Post by Zuu » 28 May 2011 16:17

Note that your AI will pay a yearly fee for each station it has of about 500 pounds per transport mode it has. (In 1950)
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

svetovoi
Engineer
Engineer
Posts: 87
Joined: 12 Oct 2007 14:07

Re: Terron AI

Post by svetovoi » 29 May 2011 14:19

AI update.
Previous version had a horrible typo in the very AI core which is now fixed.

Brumi
President
President
Posts: 904
Joined: 18 Jul 2009 17:54

Re: Terron AI

Post by Brumi » 01 Jun 2011 15:05

I found this while running my test game:
roads!.png
(526.51 KiB) Downloaded 2 times
Becoming old AI-ish? :D
Maybe the AI failed to build a road to Evilwell Woods...

svetovoi
Engineer
Engineer
Posts: 87
Joined: 12 Oct 2007 14:07

Re: Terron AI

Post by svetovoi » 01 Jun 2011 17:34

It's not a bug, it's a feature :)

Should resolve jams.
Unfortunately, after the first expansion vehicles not always follow the new road and AI builds additional road second time and then third, and you see the result.

I think it's still better than
Attachments
jam.png
jam.png (101.81 KiB) Viewed 13074 times

User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9282
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Terron AI

Post by planetmaker » 01 Jun 2011 17:53

ac84 wrote:It's not a bug, it's a feature :)
I think it's still better than
IMHO not really. The jam in the image you show is caused by the drive-through road stops which cause all other vehicles to wait. You can detect those on the prospective route and build a detour around those, if needed. But these large patches of road... are not nice nor will they help really as the problem is something else (as explained).

svetovoi
Engineer
Engineer
Posts: 87
Joined: 12 Oct 2007 14:07

Re: Terron AI

Post by svetovoi » 02 Jun 2011 11:02

planetmaker wrote:IMHO not really.
This screenshot shows only about 1/3 of the actual jam. Are you still sure?

Stations placement is not always main cause of the jams, at least from my observations. Jams become really huge problem(as above) because of breakdowns. When many vehicles with relatively low reliability follows one road and several of them breaks it slows all the line. Reliability of all vehicles in the line goes down and this leads to even more breakdowns. It's like chain reaction. When amount of vehicles reaches critical mass(usually because several AIs use one road) then entire route becomes one huge jam. And construction of additional roads resolve this issue.

While, surely, current building algorithm is far from optimal, I'll choose aesthetically unpleasant and even ugly landscape over constant 100 vehicles jam any day.

But I'm looking forward for more intelligent solution.

Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 2 guests