[AI] RailwAI

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
RailwAI
Engineer
Engineer
Posts: 75
Joined: 22 Jul 2018 20:30
Location: Headquarters

Re: [AI] RailwAI

Post by RailwAI »

With expansion limit on, RailwAI doesn't want to become larger than other companies around. If you would join the game and build your own routes, it might expand again. It can sometimes occur that planes aren't used, depending on the shape of cities. It might decide later to start with planes, but it requires at least enough cash. Thanks for your bug reports, those will be solved in the next release (and I found 2 more bugs myself that were already longer present).
User avatar
odisseus
Director
Director
Posts: 552
Joined: 01 Nov 2017 21:19

Re: [AI] RailwAI

Post by odisseus »

The AI seems to be confused by narrow gauge tracks. It builds dual tracks (which have a speed limit) and attaches narrow gauge wagons (which have a still lower speed limit and very low capacity) to a normal engine; as a result, the train goes at 20 km/h when 120 km/h would be possible with normal wagons.
narrow-gauge.png
narrow-gauge.png (40.24 KiB) Viewed 9917 times
Attachments
narrow-gauge-2.sav
(98.63 KiB) Downloaded 196 times
User avatar
RailwAI
Engineer
Engineer
Posts: 75
Joined: 22 Jul 2018 20:30
Location: Headquarters

Re: [AI] RailwAI

Post by RailwAI »

It was indeed confused by the fact that only some carriages and track types have speed limits. I have fixed some bugs and added more options to regulate the company expansion. Therefore version 25 (now available) should always work better than 24. The changelog:
  • Bugfix: loading a savegame while creating a new service with ships
  • Bugfix: do not send helicopters to hangars instead of the terminal
  • Bugfix: repairing pathfinder was sometimes unable to restore paths along diagonal tracks
  • Bugfix: savegames while using the repairing pathfinders sometimes caused bad behaviour after reloading
  • Trains: better support for narrow gauge newGRF
  • AI Settings: more options to limit company expansion
Jacobian
Engineer
Engineer
Posts: 2
Joined: 19 Aug 2020 16:50

Re: [AI] RailwAI

Post by Jacobian »

Hi. Where can I download this AI? Or where can I download AI: trAIns

What is the best AI for Railway only? I´m looking for Railway AI because i like to play with ships and Aircraft. So i´m looking for AI which will build Trains instead of me. Admiral AI sucks. Admiral AI build only simple trains.
User avatar
RailwAI
Engineer
Engineer
Posts: 75
Joined: 22 Jul 2018 20:30
Location: Headquarters

Re: [AI] RailwAI

Post by RailwAI »

Hi Jacobian,

This AI is available via the in-game content. After starting openTTD, you can choose the option 'check online content' and search for RailwAI. When you select RailwAI, you can press the download-button on the right to download it.
In order to play with/against RailwAI, you should tell openTTD to use it. After downloading, you can select 'AI/Game Script Settings' from the main screen in openTTD. Here you can select the artificial competitors and configure them.

Enjoy!
User avatar
RailwAI
Engineer
Engineer
Posts: 75
Joined: 22 Jul 2018 20:30
Location: Headquarters

Re: [AI] RailwAI

Post by RailwAI »

It was quite a while ago since the last update, but a new version 26 is available on BaNaNaS. The changelog:
  • Minimum required OpenTTD version increased to 1.10
  • Bugfix: repairing pathfinder should not update its counters in testmode
  • Bugfix: crash when trying to place a railway signal on a tile without rail
  • Allow to transport two cargo types in one train (e.g livestock/grain or passengers/mail)
  • Rail pathfinder: Take slope steepness into account
  • Do not use slow trucks or trains for long distance transport
  • Do not build stations that can not be used by articulated road vehicles if articulated road vehicles are used
  • Do not try to convert a rail type if crossings are present that can not be converted
  • Increase financial buffer, such that economical recessions are less of a problem
  • Allow to use different roadtypes over the years when RattRoads/U&Ratt newGRF is activated
  • Bugfix: do not remove water depots that are still in use
  • Automatically remove water depots that are not in use
  • Use the livery colour in the company name with a chance of 6%
User avatar
RailwAI
Engineer
Engineer
Posts: 75
Joined: 22 Jul 2018 20:30
Location: Headquarters

Re: [AI] RailwAI

Post by RailwAI »

I only noticed recently that is has difficulties on recognizing the default maglev locomotives, I'll solve it in the next update.
sevenfm wrote: 22 Oct 2019 18:29 Found two problems with this AI when tried it in my game (JGR 0.32):
1. It does not understand road types (I used rattroads) - it builds standard expensive road instead of cheapest, even though the fastest vehicle can run at 30 km/h at that time.
2. It builds intercity roads which can hardly pay for their maintenance at that time, instead of building local bus networks in big towns which could be very profitable and provide a cash for later expansion.
Does it work better now, or do you have any suggestions on improvement for new road types?
User avatar
RailwAI
Engineer
Engineer
Posts: 75
Joined: 22 Jul 2018 20:30
Location: Headquarters

Re: [AI] RailwAI

Post by RailwAI »

Version 27 is now available on BaNaNaS. The changelog:
  • Take the freight weight multiplier into account when determining the amount of required locomotives in a train
  • More frequent use of railway tunnels when the world has hills
  • Several pathfinder optimizations
  • Allow slopes under a railway station or airport, as long as it can be built
  • Use less planes on a single route
  • Use the monorail Millenium Z1 locomotive as a locomotive
  • Improved support for different trains NewGRF (Czech Railways set, 2cc set and more)
  • Bugfix: compute size of financial buffer correctly
  • Bugfix: do not forget to electrify railway depots
  • Bugfix: do not occasionally remove a railway bridge of another railway line when building a new railway line on adjacent tiles
  • Bugfix: railway lines were not always removed after a decision to sell all vehicles on the line
openttdfan2020
Engineer
Engineer
Posts: 19
Joined: 31 May 2019 21:26

Re: [AI] RailwAI

Post by openttdfan2020 »

Hey RailwAI, I'm curious about the Rail Expansions like (2 3 or 5 tracks) to industries (if Freight Service) and towns (if Passenger Service), It will be super cool that you add Rail Yards with Depots, 5 Tracks Freight Station, and 5 Tracks Terminal. Maybe you can support Canadian Trainset and many Unsupported Trainsets.
It might be really cool idea when's there's the next update. 8)
User avatar
RailwAI
Engineer
Engineer
Posts: 75
Joined: 22 Jul 2018 20:30
Location: Headquarters

Re: [AI] RailwAI

Post by RailwAI »

What do you mean with the first sentence?
Can you be more specific in the problems of the AI with the canadian trainset? If I don't know what's the problem, I can not try to fix it.
User avatar
RailwAI
Engineer
Engineer
Posts: 75
Joined: 22 Jul 2018 20:30
Location: Headquarters

Re: [AI] RailwAI

Post by RailwAI »

Version 28 is now available. Changes:
  • Improved financial management (bank loans)
  • Allow to demolish houses to build a railway track
  • Allow to build train stations on sloped tiles
  • Rail pathfinder optimizations
  • Use more than one depot on longer passenger railway lines when breakdowns are enabled
  • Bugfixes in the function to add wagons to an existing train
  • Bugfix: don't build disconnected railway track after building a bridge to cross another, diagonal railway line
  • Bugfix: on a single track railway line, don't place signals near the a station on such that deadlocks occur
AAAHogEx
Engineer
Engineer
Posts: 109
Joined: 30 Jan 2022 15:37
Location: Japan

Re: [AI] RailwAI

Post by AAAHogEx »

Hi.

I was trying with some AIs and Railwai crashed. (no newgrf)
Attachments
1960-05-06.png
(3.36 MiB) Not downloaded yet
1960-05-06.sav
(2.38 MiB) Downloaded 87 times
xarick
Transport Coordinator
Transport Coordinator
Posts: 335
Joined: 26 Feb 2015 00:52

Re: [AI] RailwAI

Post by xarick »

RailwAI, I wanted to ask if you were aware of this bug: https://github.com/OpenTTD/OpenTTD/pull ... 1371132045

AIGroup.GetProfitLastYear gets the profit vehicles had last year, but it doesn't include the profits of vehicles below minimum age, while AIGroup.GetProfitThisYear does.

I ask, what were you expecting the function to do when you coded it in RailwAI? When trying to read your code seems that you wanted to include (or exclude) some groups if the vehicles are not old enough.
Formerly known as Samu
User avatar
RailwAI
Engineer
Engineer
Posts: 75
Joined: 22 Jul 2018 20:30
Location: Headquarters

Re: [AI] RailwAI

Post by RailwAI »

Thanks for mentioning it here. I was not aware of the bug but assumed it would give the same value as on the GUI. I indeed exclude some groups if the oldest vehicle is too young, but I think this noAI bug might have had some negative impact on my AI. Probably not very significant, since I didn't found the bug during testing. For me it's safe if the behaviour of this function changes. Thank you for finding this issue and solving it! :D
User avatar
RailwAI
Engineer
Engineer
Posts: 75
Joined: 22 Jul 2018 20:30
Location: Headquarters

Re: [AI] RailwAI

Post by RailwAI »

Version 29 is now available
  • Passenger trains now stop at the middle of the platform
  • Planting trees now consumes less time per group of trees planted
  • Connect railway depots with two tracks instead of one
  • Be able to continue converting rail track types on the map from a savegame
  • Be able to build slightly different station throats
  • Replace road vehicles with faster road vehicles if available
  • Check town ratings when planning new train stations
  • Improvements on making railway bridges double track
  • Bugfix: do not accidentally remove a part of the first track when building parts of the second track
  • Bugfix: unintended division by zero (thanks for reporting, AAAHogEx)
AAAHogEx
Engineer
Engineer
Posts: 109
Joined: 30 Jan 2022 15:37
Location: Japan

Re: [AI] RailwAI

Post by AAAHogEx »

Crashed
Attachments
[未命名]、1997-05-19#1.png
(1.86 MiB) Not downloaded yet
[未命名]、1997-05-19.sav
(2.6 MiB) Downloaded 49 times
User avatar
Redirect Left
Tycoon
Tycoon
Posts: 7234
Joined: 22 Jan 2005 19:31
Location: Wakefield, West Yorkshire

Re: [AI] RailwAI

Post by Redirect Left »

Whilst mass testing for this thread, I came across an instance where the bot deleted some track, seemingly without realising there were still trains on it, and it resulted in it being the first AI I've tested to end up crashing its own trains.
Site overview -
2023-03-17 15_58_41-OpenTTD 13.0.png
2023-03-17 15_58_41-OpenTTD 13.0.png (989.78 KiB) Viewed 2251 times
The AI console output -
2023-03-17 16_01_28-OpenTTD 13.0.png
2023-03-17 16_01_28-OpenTTD 13.0.png (28.62 KiB) Viewed 2251 times
and the game, saved as soon as I noticed the crash, in case it is helpful, be warned it is chaotic due to all the AIs
TEST 5.sav
(4.14 MiB) Downloaded 54 times
Image
Need some good tested AI? - Unofficial AI Tester, list of good stuff & thread is here.
User avatar
RailwAI
Engineer
Engineer
Posts: 75
Joined: 22 Jul 2018 20:30
Location: Headquarters

Re: [AI] RailwAI

Post by RailwAI »

Thanks for reporting. I expect one piece of track accidentally was demolished for some reason, but it is probably hard to reproduce. In such a case it recognizes a dead end track end removes more. I'll give it an attempt with your savegame, but I am not sure if I can find the original cause.
It is true that the AI watches if vehicles are crashed (that is the message you see in the log), trying to prevent more road vehicles crashing on the same level crossing. A crashed train is not handled further.
AAAHogEx wrote: 17 Mar 2023 09:24Crashed
Thank you for reporting! It will be fixed in the next release.
User avatar
RailwAI
Engineer
Engineer
Posts: 75
Joined: 22 Jul 2018 20:30
Location: Headquarters

Re: [AI] RailwAI

Post by RailwAI »

Version 30 is now on bananas and it should handle the situation submitted by Redirect Left much better. Following the vision in the first post (RailwAI tries to solve problems) I made improvements at multiple stages after a piece of track is deleted accidentally. Hence the following changelog:
  • Prevent crash invalid type 'null' on railtrackplan line 1105
  • Improvements on rebuilding one missing tile of railway track
  • Convert normal signals to path based signals if a train is lost due an incorrectly placed signal
  • Build depots to sell trains on a railway line that is being removed
  • Small changes to financial company strategy
TTDManager689
Engineer
Engineer
Posts: 5
Joined: 18 Oct 2023 19:47

Re: [AI] RailwAI

Post by TTDManager689 »

Hello, this is my first time to report the issue.

I've just noticed a issue on a AI on trying to build a tram network.
It seem once building a tram route it hasn't succeeded every time it did that even when installing Newgrfs with trams included.

The example as seen on the attachments below the script tells me the following issue:

No path found :-( at 183469
result: false
Something went wrong while executing a plan. Undoing...

ERR_NONE
Idea could not be executed

While I'm trying to find a solution I wonder if it is a bug otherwise is there any solution I should try? Thanks for reading!
Attachments
Boningville Transport, 1943-08-01.png
RailwAI Tram line issue.
(752.01 KiB) Not downloaded yet
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 16 guests