Transport Tycoon Forums

[AI] RailwAI
Page 1 of 2

Author:  RailwAI [ Sun Jul 29, 2018 3:07 pm ]
Post subject:  [AI] RailwAI

Hi all!

I am happily proud to present you a new AI called RailwAI. RailwAI is a best-effort, random behaving artificial player that can use ships, trains and road vehicles. Available through Bananas.
Some features of RailwAI:
- Build railway lines with 2 tracks (I hope you like the building style)
- Build roads, tramways and canals
- Use different types of available trains, bridges etc.
- Connect multiple cities on a single passenger line
- Executing building plans will be continued when loading a savegame
- Sometimes things go wrong (blocked canals, too long trains), RailwAI will hopefully try to solve the problem
- Support for (hopefully) a lot of NewGRF without creating weird train combinations (like, putting freight carriages behind a passenger unit)
- Behaviour is random. A company might go bankrupt when expensive vehicles are bought.
- It is called RailwAI, but it might have a preference for roads (because those are cheap)


Author:  RailwAI [ Mon Jul 30, 2018 6:33 pm ]
Post subject:  Re: [AI] RailwAI

The AI was hardly transporting cargo in the intial version. I found a few bugs related to cargo, so I have pushed a second version to BaNaNaS.
Changelog of version 2:
  • Bus services should now always be between 2 different cities/villages, of which one is not too small.
  • Better search for suitable location to build a dock for ships
  • Faster switching from building 2 tracks over the full line to using 2 tracks partially
  • Bugfix: selecting a cargo type to transport now works properly
  • Bugfix: if ships are available, trains and trucks can still be used to transport cargo

Author:  Hyronymus [ Mon Jul 30, 2018 7:50 pm ]
Post subject:  Re: [AI] RailwAI

This sounds cool, a realistic railway building AI that also uses different vehicle types. When I run into spare time I will surely check this out.

Author:  RailwAI [ Wed Aug 01, 2018 9:58 am ]
Post subject:  Re: [AI] RailwAI

Thank you. I am currently trying to make bus services and passenger train services between smaller towns more profitable, that will hopefully be the next update. It is rather hard to do so without timetables.

Author:  RailwAI [ Wed Aug 08, 2018 7:32 am ]
Post subject:  Re: [AI] RailwAI

Version 3 is available. Changelog:
  • Bugfixes: more succes in building road tunnels
  • Bus stops within large cities will be less close to eachother
  • Road depots are built closer to a road station
  • More truck stations can be built around factories
  • Faster pathfinder for roads on longer distances
  • Loan is set dynamically
  • Old vehicles will be replaced or sold
  • Unused stations will be removed
Edit: forgot to correct a small mistake in the last mentioned feature. You can download version 4.

Author:  Brumi [ Mon Aug 20, 2018 1:36 pm ]
Post subject:  Re: [AI] RailwAI

This AI is amazing!

Left it running in a heavily NewGRF'ed (FIRS and various vehicle sets) game, and I have not seen a single error so far! And it's very good to see that it's a multi-profile AI, ships are especially welcome :)

The only unusual thing I saw was that the AI built a really long canal right at the beginning of the game. And I was thinking, "How on earth did it not crash the company?", but then I saw that canal costs are lowered with SQUID significantly. The company was a success, obviously.

Author:  RailwAI [ Fri Aug 24, 2018 9:27 pm ]
Post subject:  Re: [AI] RailwAI

Thank you! It took me quite some time to develop something that I found ready for publication. I currently like it more to adjust some changes and watch a few AI playing openttd, than to play the game myself :P

Building a long route as the first route can be a large risk however. During test runs, I have already seen RailwAI going bankrupt when the cost estimation before was too low, but it will always depend on game settings. In your case, it was probably a bit of luck too.

Version 5 is now uploaded. The changelog:
- Bugfix: Reloading a game after the AI had crashed, sometimes caused the AI to immediately crash again
- Bugfix: Always use the corresponding rail type to build rails in front of a depot (instead of sometimes a different, compatible one)
- Bugfix: an unconnected station track was sometimes allowed
- Building less level crossings, as those often cause accidents when there is heavy road traffic
- Do not always reduce length of passenger trains, only if there will be not enough passengers
- Better re-use of existing canals
- When the company has enough money, it now can build statues

Author:  Brumi [ Mon Aug 27, 2018 7:14 pm ]
Post subject:  Re: [AI] RailwAI

Found something that may be of interest to you:

railwAI_trams.png [186.77 KiB]
Not downloaded yet

The pink player (railwAI) tried to make a tram connection in the SW-NE direction. I don't know what happened here, but it is certain that some of the trams actually made it to the NE side. Does the AI try to avoid level crossings by building detours? I see that the AI is constantly trying to make adjustments to this route, but for some reason it fails to see that the tracks coming from the SW are not connected.

Savegame is attached.

railwAI_test_trams.sav [576.72 KiB]
Downloaded 63 times

Author:  RailwAI [ Tue Aug 28, 2018 9:39 pm ]
Post subject:  Re: [AI] RailwAI

The AI is indeed trying to remove level crossings, because on those crashes can occur between road vehicles and trains. The disconnected tramway is a bug I knew of, and I was already working on that part of the problem. I don't see directly why it keeps failing to properly remove the roads. I'm definitely going to tackle the issue in the next update, thank you for the savegame.

Author:  RailwAI [ Fri Aug 31, 2018 9:36 pm ]
Post subject:  Re: [AI] RailwAI

If you now update the AI, it should stop panicking over the railroad crossings and most crossings will be removed.

The changelog for version 6:
- Bugfix: some corner combinations were not always allowed
- Bugfix: no more blocking of locks when building new canals
- Bugfix: selecting correct tiles when planning a detour for a railroad crossing
- No more weird U-turns ("large pools") in new canals
- Railway lines with single-track parts will take less time
- Removing dead-end roads built by the company
- Reconnect tramways that were accidentally disconnected (can happen when a detour is made for a railroad crossing)
- Cargo services cannot are not anymore allowed to pick up cargo at the drop off location
- Borrowing more money from the bank to buy a train, if required

Author:  RailwAI [ Tue Sep 04, 2018 5:41 pm ]
Post subject:  Re: [AI] RailwAI

Short changelog for version 7:
- Bugfix: no more accidental removal of tiles of a different station

Author:  Dr. B. Ching [ Tue Nov 06, 2018 8:55 am ]
Post subject:  Re: [AI] RailwAI

I've used your AI in several test games and came away impressed. It's been completely crash-free thus far, uses a pleasingly wide variety of engines (even odd stuff like HEQS' freight trams or 600mm narrow gauge train) and seems to do quite well for itself most of the time. The only persistent problems encountered are centered around waterways:

  • If 90° turns for ships and trains are forbidden, the AI doesn't always take this into account when building canals, and this leads to ships stuck in infinite loops around locks, depots or docks.
  • Construction of docks sometimes interferes with locks, blocking access.
  • Some canals are simply an unnecessary expenditure. I don't know how the pathfinder is set up, but the shortest route (canal through a tiny island) doesn't make sense when you could just go around it for free.

Kind Regards,
The Axe

Precombe Transport, 1936-07-08.png
Precombe Transport, 1936-07-08.png [ 161.23 KiB | Viewed 3607 times ]

Author:  xarick [ Sat Nov 10, 2018 3:04 pm ]
Post subject:  Re: [AI] RailwAI

RailwAI v7, the index '0' does not exist

Unnamed, 1953-06-25.sav [17.57 MiB]
Downloaded 57 times
Unnamed, 1953-06-26.png [188.08 KiB]
Not downloaded yet

Author:  nihues [ Sun Nov 11, 2018 5:12 pm ]
Post subject:  Re: [AI] RailwAI

Just started a hard game (normally do alone) to see what happens with 6 RailwAI, only red made barelly profit in 10 years, with ships, trains never got money until now, saw this attached :roll: , otherwise it's all nice made, maybe too much double tracks for starting (low starting money, but high loans, high construction and running costs... ). Saw some trains with 1 cargo wagon only (using Polish PKP Set that need to use 2 types of cargo - one with brakes, maybe that's the problem? but saw trains with normal size too).

There was one option on NoNoCab AI wich I like, that could be implemented? "try to stay away from already serviced industries" so we don't get a lot of stations on same place

Black & Co., Apr 10th, 1935.png [1.31 MiB]
Not downloaded yet

Author:  RailwAI [ Sun Nov 11, 2018 8:31 pm ]
Post subject:  Re: [AI] RailwAI

Thanks for your replies!

The pathfinder for ships is a modified version of the default A* pathfinder, in an attempt of realizing a fast pathfinder. Sometimes it indeed chooses an expensive option when going around an island would be a possibility too. I didn't know that the 90-degree-turn setting also affected ships. I even don't know why, but when I forbid ships to turn 90 degrees, they still can make 90 degree turns in canals (original pathfinder, YAPF or NPF). Only 180 degree turns go wrong, but I think those should already be avoided in most cases by the AI. Do you have a screenshot with an example of an impossible turn for ships? For the blocking issue I think how I can solve it.

The crash occured when the AI tried to add more stations on the route of a bus with empty orders. The crash should not occur anymore in the next version of the AI (not yet published, because I also made some other changes that do not have yet the results I was expecting). What a massive savegame by the way, my PC has real difficulties running that one.

I'll check the behaviour of the AI with the Polish PKP set and do my best to learn the AI to make more profitable routes in hard games. Nevertheless, a train with 1 cargo wagon could have been normal behaviour: when there is not enough money to buy more carriages, a short train is usually better than no train. The AI is able to buy more carriages later on (or sell carriages when it thinks a train is too long).
If you have an example of a lot of stations on the same place, it would be helpful for debugging. RailwAI should have a strong preference to choose industries that are not serviced yet, because the best way of making money is to have an own set of clients (industries).

Author:  Dr. B. Ching [ Mon Nov 12, 2018 9:53 am ]
Post subject:  Re: [AI] RailwAI

To be fair, I don't fully understand ship pathfinding, but they normally seem to be restricted to 45° turns (one per tile to navigate a 90° bend of the canal) with the setting enabled. However, the game appears to be lenient with docks at least: should a ship be unable to depart in the "proper" way, for instance if the station is located at the dead end of a canal, no harm is done, but you do get a brief "ship xx is lost" notification. Regular pathfinding seems less forgiving.

Kind Regards,
The Axe

AI_impossible turn_dock.jpg [99.38 KiB]
Not downloaded yet
AI_impossible turn_lock.jpg
AI_impossible turn_lock.jpg [ 78.92 KiB | Viewed 2408 times ]
AI_bad bouey placement.jpg [69.86 KiB]
Not downloaded yet

Author:  nihues [ Mon Nov 12, 2018 10:34 am ]
Post subject:  Re: [AI] RailwAI

RailwAI wrote:
Thanks for your replies!

If you have an example of a lot of stations on the same place, it would be helpful for debugging. RailwAI should have a strong preference to choose industries that are not serviced yet, because the best way of making money is to have an own set of clients (industries).

Didn't know that! Thats a good news! I don't have a problem with AI getting my industries but if they do I'll report, for now no problems!

For the double track, forget it, it's good, saw some exemples using 1 track and only double track for bypass.

Author:  xarick [ Tue Nov 13, 2018 2:25 am ]
Post subject:  Re: [AI] RailwAI

Hey. It seems the crash I last reported doesn't originate from the AI itself,

Author:  RailwAI [ Tue Nov 13, 2018 12:06 pm ]
Post subject:  Re: [AI] RailwAI

I was already thinking that it probably was related to a corrupted order list. Nevertheless, the crash could (theoretically) also occur in some rare cases when a player uses the magic bulldozer to remove some stations, or when the AI buys another company (I'm planning to implement that in future). Crashes should always be avoided, thus it was worth 3 checks of 1 line of code each :wink:

I am currently testing with the PKP train sets and I'm able to get crashes when trains are used that consists of a locomotive and dining cars only: the train is then not able to carry passengers :bow:

Author:  RailwAI [ Tue Nov 13, 2018 9:15 pm ]
Post subject:  Re: [AI] RailwAI

I tried on hard settings, but I clearly see why trains probably are not used in the first years: when the maximum loan is only $100.000, I barely have enough money to buy a single train. Then ships and buses/trucks are more feasible.
When RailwAI is using a single-track railway line (with passing sections), it does because it couldn't build a proper two-track line (for whatever reason). I have improved, but I am still not really content with the difficulty this AI has with building passing sections. It's high on the to-do-list, as well as using less buoys when ships are used.

Changelog for version 8 that is now available:
- Rail: Building (slightly) more passing sections
- Passenger trains: do not use carriages that offer 0 additional seats
- Add setting to regulate the amount of trees that the company will plant when it has a lot of money
- First transport service is now preferred to not be operated with ships. RailwAI will get less often bankrupt.
- Build additional buoys 8 tiles before and after a lock, such that ships get lost less often
- An unprofitable ship can be sold quicker when a new dock is built nearby the location of the ship
- Disallow U-turns (double 90 degree turns) for ships
- Remove disconnected railway tracks (but first reconnect bridges that were accidentally not connected properly to the next tile with track)
- Do not build docks adjacent to locks
- More possible company names
- When the company has a lot of money, it will start building some tunnels in existing railway lines

Page 1 of 2 All times are UTC
Powered by phpBB © 2000-2019 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2019.