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
Posts: 14
Joined: 24 Aug 2007 15:43


Post by Jaume »

Hi all!

This is a new AI, based of code of SimpleAI v12 (thank you so much, Mr Brumi), but isn't another (or better) SimpleAI: this AI makes very profitable single point to point large routes, with lots of long trains each one. It is very configurable, and is almost stable. The default configuration makes routes up to 1920 tiles long, with 15 tiles long trains. Of course, it can be configured to emulate SimpleAI, and it works better than this AI, it can recover unfinished routes when loading games (in some cases), and test if it can build new routes before spend money on its construction. Another features are state of owner's company building, managing trains while pathfinding, better passing lanes and stations...

Goals: This AI was build to create more realistic cargo routes and trains. Like SimpleAI, this AI can manage trains, buses and trucks (and trams, but not tested) and planes. But most of tests are done only with cargo trains, no other type of vehicles are well tested. This isn't a winner AI, but can do lots of very profitable cargo routes that looks real cargo lines.

This is the changelog from SimpleAI v12:

Don't remove unprofitable trains (I don't like how it works).
Longer trains, stations and passing lanes up to 7 tiles (configurable).
Single destination stations.
More than 2 trains per route.
Allow train routes up to 200 tiles.
Better passing lanes without unnecessary signals.

Allow 1, 3, 4 and 5 passing lanes.
Allow long train routes, up to 910 tiles (configurable).

New BuildPassingLanes function.
Allow up to 15 passing lanes (configurable).
Allow long road routes, up to 230 tiles (configurable).
Allow long train routes, up to 1640 tiles (configurable).
Allow long aircraft routes, up to 1640 tiles (configurable).
Disallow new/close industries logging.
Allow to add more trains on a route, then new routes are started with only one train.
Disallow large bridges and tunnels if we don't have more than 250k (inflated).
Wait if we need money to finish a rail/road route.
Check routes and events while pathfinding.
Don't send to depot fully loaded trains.
Don't reverse trains to find a depot.
Don't send to depot more than one vehicle if we can't paid it.
Restart unfinished routes when load a saved game, if it is posible.
Build statue if we have some money.
Prevent to add new train if empty train is waiting for cargo.
Forbid non-flat passing lanes (configurable).
Set name to stations.
Better aircraft manager.
Now works well if forbid_90_deg game setting is set to true.

Check if we can build all stations and passing lanes before build it.
length of trains now depends of industry production.
Better passing lanes.
Updated max lenght of aircfraft and rail routes.

Prevent crash when FindService() runs while month change.
Diagonal passing lanes.
Better order flags.
Bridges and tunnels on passing lanes.
Build stations as closest as possible to industry (configurable).
Permit 15 tiles long trains.
Allow double and triple traction.
Allow long train routes, up to 1920 tiles (configurable).

Don't destroy active routes when demolish join stations (bug).
Don't crash when load game with builded but not finished route (bug).

BUGS: Failing passing lane construction may create some rail-trash.

TODO: This AI doesn't close unprofitable routes, this isn't good for non-stable economics games. This AI doesn't estimate tunnel building costs when inflation is set to true, then it may fail to build new routes.

Recomended settings: this AI may build 15 tiles long trains, so remember to set limits of trains and stations from configuration. In some cases it can build lines with 90º turns, so don't forbid this turns. Inflation may be set to false.

Enjoy it!
(330 KiB) Downloaded 6 times
Last edited by Jaume on 09 Jan 2021 22:47, edited 8 times in total.
Posts: 14
Joined: 24 Aug 2007 15:43

How to remove manually a (unprofitable) route?

Post by Jaume »

How to remove manually a (unprofitable) route?

1.- Remove it's train depot.
2.- Build a new train depot in same place.
3.- Send all trains to depot.
4.- Sell all trains.
5.- Wait. This AI removes all routes that doesn't have vehicles.
Last edited by Jaume on 07 Jan 2021 11:51, edited 1 time in total.
Posts: 14
Joined: 24 Aug 2007 15:43

Some images

Post by Jaume »

Some images:
(1.04 MiB) Not downloaded yet
(438.23 KiB) Not downloaded yet
(554.83 KiB) Not downloaded yet
User avatar
Traffic Manager
Traffic Manager
Posts: 245
Joined: 11 Aug 2019 18:15
Location: Massachusetts, USA

Re: SuperSimpleAI

Post by 2TallTyler »

This looks nice. I’ll have to try it out.

EDIT: Would you care to upload this to Bananas? That would automate downloading the pathfinder dependencies and make installation easier.
Posts: 14
Joined: 24 Aug 2007 15:43

Re: SuperSimpleAI

Post by Jaume »

Would you care to upload this to Bananas?

I'm sorry, but GitHub doesn't works on my old PC.I try it later.
Posts: 908
Joined: 18 Jul 2009 17:54

Re: SuperSimpleAI

Post by Brumi »

Whoa, it's exciting to see another fork of SimpleAI, I have to try it :) Also it's funny to have an AI named SuperSimpleAI which is actually more advanced than SimpleAI ;)
I apologize for all the headaches my old code caused for you!

I only see one absolutely minor issue so far: I'm running two instances of this AI, and only one of them renames its stations (e.g. Brown Freight SRC_22 (1964)), the other one keeps the default names. The only difference between them in configuration is the log date format. If the AI reads station names for extra info (like, I've seen .tmp-named stations popping up here and there), this might be an actual issue instead of just visuals. Random guess: maybe the station names would be too long, given the company name F. Cuthbert Inforporated?

And I have a question for you:
Jaume wrote:v17:
Prevent crash when FindService() runs while month change.
Is this crash possible in SimpleAI as well? I'll also have to fix it if it's in my code :)
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 3 guests