[AI] AAAHogEx

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

xarick
Transport Coordinator
Transport Coordinator
Posts: 341
Joined: 26 Feb 2015 00:52

Re: [AI] AAAHogEx

Post by xarick »

Hello again. I have another crash report, on v75.
Attachments
Unnamed, 1958-07-20.png
(172.15 KiB) Not downloaded yet
Unnamed, 1958-08-12.sav
(10.78 MiB) Downloaded 36 times
Formerly known as Samu
AAAHogEx
Engineer
Engineer
Posts: 117
Joined: 30 Jan 2022 15:37
Location: Japan

Re: [AI] AAAHogEx

Post by AAAHogEx »

xarick wrote: 04 Mar 2024 23:05 Hello again. I have another crash report, on v75.
Thanks again. Corrected version v77 has been released to bananas.
Other changes are here.
https://github.com/rei-artist/AAAHogEx/ ... /v75...v77
Save data from previous versions is incompatible.
GelGiGue
Engineer
Engineer
Posts: 4
Joined: 20 Feb 2024 23:04

Re: [AI] AAAHogEx

Post by GelGiGue »

A few suggestions. The AI will always build light aspect signals no matter the time period, which can look very bizarre, so an option to force building of semaphores before the date defined in the "automatically build semaphores before X" setting would be great. 2nd, in later versions it seems that the AI crashes before going bankrupt, I have not seen a bankruptcy in some time. Anyways, back when it would go bankrupt, it would always start right back up, so I think it would be cool if that could be disabled for tournament style games. Another, more indulgent request is an option to prevent closing lines down, I love seeing it build comprehensive networks. That and almost every single time a line gets more than one station, 7 times out of 10 that middle station will close. :bow:
skc
Traffic Manager
Traffic Manager
Posts: 177
Joined: 17 Sep 2022 02:02

Re: [AI] AAAHogEx

Post by skc »

GelGiGue wrote: 07 Mar 2024 18:09 <snip>
2nd, in later versions it seems that the AI crashes before going bankrupt, I have not seen a bankruptcy in some time. Anyways, back when it would go bankrupt, it would always start right back up, so I think it would be cool if that could be disabled for tournament style games.
<snip>
I'm fairly sure that the re-starting of any AI is not something the individual AI can influence. When you enable AIs in your game, you can define how long the game waits before it starts up that AI. If the AI goes bankrupt, the game will start a new company using the vacated AI slot.
AAAHogEx
Engineer
Engineer
Posts: 117
Joined: 30 Jan 2022 15:37
Location: Japan

Re: [AI] AAAHogEx

Post by AAAHogEx »

Thank you for your request.
GelGiGue wrote: 07 Mar 2024 18:09 A few suggestions. The AI will always build light aspect signals no matter the time period, which can look very bizarre, so an option to force building of semaphores before the date defined in the "automatically build semaphores before X" setting would be great.
This is certainly true. I will consider implementing it.
2nd, in later versions it seems that the AI crashes before going bankrupt, I have not seen a bankruptcy in some time. Anyways, back when it would go bankrupt, it would always start right back up, so I think it would be cool if that could be disabled for tournament style games.
After an AI company is launched, if you set AI Settings->Maximum no. competitors to 0, it will not be revived after going bankrupt.
Another, more indulgent request is an option to prevent closing lines down, I love seeing it build comprehensive networks. That and almost every single time a line gets more than one station, 7 times out of 10 that middle station will close.
Middle stations often don't produce any profit, so they are usually discarded. AAAHogEx has a policy of prioritizing profits, so it would be nice if there was a situation where intermediate stations could generate profits.
GelGiGue
Engineer
Engineer
Posts: 4
Joined: 20 Feb 2024 23:04

Re: [AI] AAAHogEx

Post by GelGiGue »

your reply
Thank you for considering. I have actually found the trick with the AI number a couple days ago, very handy. Another thing I wanted to ask about was that the ai seems to have a knack for tunneling one track, but the track next to it goes over the hill.
Last edited by GelGiGue on 09 Mar 2024 15:17, edited 1 time in total.
AAAHogEx
Engineer
Engineer
Posts: 117
Joined: 30 Jan 2022 15:37
Location: Japan

Re: [AI] AAAHogEx

Post by AAAHogEx »

GelGiGue wrote: 09 Mar 2024 14:49 I have actually found the trick with the AI number a couple days ago, very handy.
I am curious what the trick is. My guess is that it relates to the name of the company?
Another thing I wanted to ask about was that the ai seems to have a knack for tunneling one track, but the track next to it goes over the hill.
I am trying to make it as same as possible, but it still seems incomplete. :roll:
AAAHogEx
Engineer
Engineer
Posts: 117
Joined: 30 Jan 2022 15:37
Location: Japan

Re: [AI] AAAHogEx

Post by AAAHogEx »

version 78 released!

[Feature] Continuous restructuring of railways


Other performance improvements at 4k4k, minor bug fixes, etc.
Save data from previous versions is incompatible.
Attachments
Continuous_rebuilding.mp4
(1.84 MiB) Downloaded 21 times
GelGiGue
Engineer
Engineer
Posts: 4
Joined: 20 Feb 2024 23:04

Re: [AI] AAAHogEx

Post by GelGiGue »

AAAHogEx wrote: 11 Mar 2024 14:51
GelGiGue wrote: 09 Mar 2024 14:49 I have actually found the trick with the AI number a couple days ago, very handy.
I am curious what the trick is. My guess is that it relates to the name of the company?
the one you had described with the limiting AI amount after the crash. you can also violently take over a company as whichever player you want to absorb the assets, that might just be a jgr thing though.
I am trying to make it as same as possible, but it still seems incomplete. :roll:
great to hear! I'm excited to try v78, it took me a few days to get around to installing it because bananas couldn't update properly even if it had a gun to its metaphorical head. i'll follow up with my thoughts after watching it.
GelGiGue
Engineer
Engineer
Posts: 4
Joined: 20 Feb 2024 23:04

Re: [AI] AAAHogEx

Post by GelGiGue »

started a game up. it had closed a line while building it, and left this stretch of track spanning where the stations were. while i was taking screenshots of the line, it crashed.

here's the screenshots, still pretty new to posting here.
Attachments
Unnamed, 1841-04-22.png
(891.73 KiB) Not downloaded yet
Unnamed, 1841-05-18.png
(747.4 KiB) Not downloaded yet
Unnamed, 1841-07-06.png
(928.7 KiB) Not downloaded yet
AAAHogEx
Engineer
Engineer
Posts: 117
Joined: 30 Jan 2022 15:37
Location: Japan

Re: [AI] AAAHogEx

Post by AAAHogEx »

GelGiGue wrote: 11 Mar 2024 19:06 started a game up. it had closed a line while building it, and left this stretch of track spanning where the stations were. while i was taking screenshots of the line, it crashed.

here's the screenshots, still pretty new to posting here.
Thank you for your report. If you save while AI is building rails, sometimes it remains. I'm going to make sure there's nothing left somehow.
xarick
Transport Coordinator
Transport Coordinator
Posts: 341
Joined: 26 Feb 2015 00:52

Re: [AI] AAAHogEx

Post by xarick »

Hi there! Got a crash.
Attachments
Unnamed, 1951-08-26.sav
(21.1 MiB) Downloaded 29 times
Unnamed, 1951-08-27.png
(374.7 KiB) Not downloaded yet
Formerly known as Samu
AAAHogEx
Engineer
Engineer
Posts: 117
Joined: 30 Jan 2022 15:37
Location: Japan

Re: [AI] AAAHogEx

Post by AAAHogEx »

Version 81 released!

[Feature] Continued construction after save/load during rail construction
Other minor bugs and adjustments

Save data from previous versions is incompatible.
GelGiGue wrote: 11 Mar 2024 19:06 started a game up. it had closed a line while building it, and left this stretch of track spanning where the stations were. while i was taking screenshots of the line, it crashed.

here's the screenshots, still pretty new to posting here.
I have changed the code around the rail building and it is less likely to occur than before.
xarick wrote: 14 Mar 2024 21:34 Hi there! Got a crash.
Thank you for everything. Fixed it!
LaChupacabra
Route Supervisor
Route Supervisor
Posts: 391
Joined: 08 Nov 2019 23:54

Re: [AI] AAAHogEx

Post by LaChupacabra »

Hey Rei :)

I've been writing this post for over a year now and I still haven't been able to publish it... There was supposed to be one short comment, but there was something else and something else. And it turned out that it would be best to approach it comprehensively, i.e. write even more. During this time, some of the comments have become outdated and I have to write some again. Okay, stop! I will post it as is.
First of all, I would like to write that you created a really impressive AI. This is the first AI that was able to cause me a problem in certain game configurations. Previously I considered ShipAI, trAIns and RailwAI as the most competitive, but now they have almost no chance against AAA. Only sometimes RailwAI can face it. You really raised the bar high. :) I like both his efficiency and even the style in which he builds. I like many of the solutions it uses, such as double depots when breakdowns are enabled, collision-free entry to stations, extending the range of stations or taking loads in both directions (or at least trying to do it). But, well, there are a few things that could be improved. :) You probably know about most of these problems, so these are not discoveries. Just a different perspective that might be useful. During this time, I collected some of these comments... ;) This will probably be one of the longest posts I have ever published anywhere. Just please don't take this as criticism or a to-do list. I apologize in advance for spamming so many comments at once. :wink:

I have divided them into five categories, which I will post in separate posts. In each of them, the first point describes the most important problem from my perspective. The last points may be just my fantasy about what I would like it to look like and how I would do it if I had more time and was not so lazy and incompetent. ;) Most of the points contain some ideas. I'm not a programmer, so some of these may be impossible, not cost-effective to implement, or may simply not fit your vision, but I hope this will be helpful in some way. These notes are mainly based on version 52 and earlier, so some of them may be out of date. I haven't verified everything, but most of it seems to be still present in version 78.
I have prepared many graphics, mainly illustrating the problems, but the limit of 3 attachments makes it impossible to post them here, so I attach most of them in compressed files.

General thoughts (1/5)

1. Stealing resources
I consider this one of the three main disadvantages of your AI. I usually played online and there, although it is not forbidden on most servers, I very rarely saw anyone doing it. If something like this happened, it was usually a troll who tried to spoil the game in various ways, or a noob who didn't understand anything and found such competition amusing. It's really irritating when you are building your transport network and instead of building theirs, someone attaches to you like a parasite and takes advantage of what you have achieved. This is especially irritating in industrial sets like FIRS, where your AI uses the entire supply delivery network created by the player. This kind of competition really isn't fun for me and I think for many other players. Please change this behavior or add a setting to prevent this type of contention.
Some AIs always avoid enterprises that are already served. Several AIs have a setting that allows you to define behavior in this respect, and for example, AIs can only take resources when the company's service level is low. I like the approach with DictatorAI the most, where with one non-literal setting you can determine the overall AI approach to competition. What I haven't seen anywhere, and which could be interesting, would be a co-op mode, which is kind of the opposite of what your and every other AI currently does. This could be one of the options that determines the AI's behavior towards others. From total competition, where AI deliberately steals even processed goods, buys transport exclusivity and does everything to be better and beat the competition, through the balanced competition mode, where AI can compete for resources, but does it only when the service level is low (below 20% ), then the neutral mode, where the AI never takes resources and also tries to avoid serving cities that are already served. The last mode would be the above-mentioned cooperative or simply friendly mode, where the AI would try to supply enterprises operated by the player or other AI and even remove its connections if the player also connected to the same enterprise.
[+] Spoiler
Image

1A. Competition between AIs for the same resource
The problem of resource theft concerns not only the AI-player relationship, but also AI-AI. The problem was especially noticeable when playing with several AIs with similar settings. Instead of trying to find another source of income, each one built exactly the same connection as the other AI. It often looked downright bizarre when there were a lot of cities on the map, often much larger ones, and all the AIs decided to compete for the same one small city, additionally spamming the entire city with their stops. Recently I noticed that you did something about it and the AIs start the game in different places. I even created a map with three islands and it turned out that each AI chose a different one and built only on its "own" island. It works and looks realy nice. :) But in my opinion there is still a problem with servicing the same enterprises and cities. I believe that AI should avoid using the same sources for both. To avoid such situations, I would see three solutions:
A. The most important thing is that when choosing a place, AI should take into account the percentage of transported cargo and more or less avoids such places.
B. To avoid building cities with stops, which looks funny but also terrible at the same time, and fighting for the same inhabitants, there should be a minimum distance between stops/station elements. I think there is already such a limit and it is 5, but only for the own stops of one station. I believe that it will look much better if the minimum distance between stops is 7 or 8 and applies to any stops, including other companies. Then not only will the city be free from their excess, but AI will also avoid senseless competition for the same resources.
C. (Probably outdated, but I'll keep it as an alternative idea) To avoid copying routes when running several AIs at the same time, you can think about adding an element of randomness. The AI could take into account several possible connections and then randomly or based on a unique number assigned to the AI (even the AI number) select one of them. Alternatively, you can also add a distance limit for the first stations (20-30 tiles), then the AI will not create a copy of the existing connection. Another way could be to build a HQ, which each AI would build in a different city and start building a company network near that city.
[+] Spoiler
Competition between AIs for the same resource.png
Competition between AIs for the same resource.png (409.93 KiB) Viewed 1153 times

2. Spamming new infrastructure instead of using the existing one
This problem applies equally to road, water and, to some extent, air transport. AI doesn't seem to take existing infrastructure into account at all (roads, stops, buoys, shipyards, canals, airports) and instead of using it, always build a new one right next to the existing one. Over time it looks really bad - the land is littered with roads and the water with buoys (before 14.0) and shipyards (still), which are often not even used. In the case of industrial airports, AI not only builds the largest it can, which often makes no sense, but also, instead of using the capacity of existing ones, it builds new ones right next to it, if it has the opportunity. This is not only a problem of appearance but also of playability. Since the AI is building up the entire map with its infrastructure very quickly, the game loses its point apart from watching what the AI is doing, because there is simply no place to build it. :( In the case of roads, many other AIs take existing infrastructure into account when calculating new routes (e.g. RoadRunner, RailwAI, LuDiAI, SuperSimpleAI). As for airports, although this is probably the simplest type of transport, no AI can sensibly use the infrastructure. I wrote more about this problem in other points.

3. Removing infrastructure
This is the third most important problem and it mainly concerns rail transport and also road transport. Over time, the AI often begins to earn less and less, mainly by "accidentally" removing track sections while building other lines. It's quite discouraging when your main rival, instead of developing, begins to sabotage its own business over time.

4. Difficulty level
For me, the current level of AI is pretty good, and aside from the annoying need to protect enterprises from theft and exess infrastructure, competing with it is a fun challenge. Finally, there is AI that can be considered a real competition. But well, I think this level may be too high and discouraging for many players. I'm afraid that if you improve some of the solutions even more, it will also become too difficult a rival even for me and other advanced players. Previously, I wrote about the possibility of adding an AI character setting from neutral or even friendly to hostile and the epitome of total competition. This is one possible solution where the setting is not literal, but it can be solved in various other ways. Another, more literal method is used by RailwAI, where you can determine the size of an AI company relative to other companies. The difficulty level may also be determined by the "AI level: Engineer / Traffic Manager / ... / Tycoon" (or "rookie / ... / pro") setting. This setting could determine not only the size of the company, but also how quickly it can be built. Currently, it is very high and unrealistic for all, even best players. It would be good if the AI in the default setting built at a similar or only slightly higher pace than human players. The pace of construction could also depend on the income difference between the best human player. The AI could slow down the construction pace if it got far enough ahead of the human players. However, if the AI begins to lag behind the player, it can also go to a slightly higher level to try to catch up.

5. Too many vehicles for connection
This problem affects road vehicles and trains. Currently, when AI sees that there is a load at the station, it buys another vehicle to transport it and does so endlessly, but beyond a certain number of vehicles, buying more vehicles stops making sense. Due to limited network capacity, it eventually becomes overloaded and traffic jams occur. AI buying more vehicles only makes the situation worse. This problem generates many AIs trying to transport all available cargo no matter what. It's an error. I noticed that if your AI becomes overloaded, probably due to losses generated by vehicles, it starts repairing the situation and it is effective, although it will probably happen again after some time. Therefore, I believe that each connection should have a maximum number of vehicles that can support it. Determining the limit can be very simple and based solely on the distance between stations. For example, for road vehicles and a connection of 100 tiles, the limit could be 20x2 (traffic density: vehicles every 5 tiles) + 4 (vehicles at stops) = 44 vehicles. You can also take into account other parameters such as vehicle speed (the higher, the lower the limit; e.g. 100 km/h = 100/100, 200 km/h = 100/200) to make the limit more adequate, but even such a simple one should help a lot and make road traffic smoother and more natural-looking. If a road connection proved insufficient, the AIs could try to build a rail or water connection in the same or another direction. Each type of transport should have a slightly different algorithm.

6. Station spread
Overall, I like this feature because it allows the AI to be much more competitive, and players usually build in a similar way, so why not him? But such unlimited spread is not always expected, especially when the AI builds more stops than needed and competes with other AIs for the same piece of the city, thus building up every possible fragment of the road. I think it would be nice to have an option like none/low/high available (this could define the maximum range, e.g. 0/5/64). Alternatively, this setting could be an integral part of the AI's attitude setting, where the total competitive option would mean maximum range and the neutral option would mean minimal or no range. However, in order for the AI not to build an excessive number of stops, as I wrote above, it would be worth adding a limitation so that the minimum distance between separate elements of the same station is 7 - 8.
What AI doesn't do, but could do, is spread industrial stations. It often happens that there is another forest or mine a short distance away, even just outside the station's range. If it were not prohibited in the settings, the AI could scan the area around the station for additional sources. This can also be done before the station is built, so that if possible, it can be placed so that it can reach more than one enterprise.

7. The "Avoid removing water" option doesn't work
Despite leaving this option enabled, the AI still raises terrain near the water, often blocking ship traffic. Sometimes it even looks as if he was doing it maliciously, because apart from raising the ground, he does nothing else in this place. I believe that "no" should mean "no". But... there could be one exception here. The idea is to raise the land in the middle of the lake to build a bridgehead. This would very rarely be problematic, so you don't necessarily need to prevent it. It is important that there is only water around the raised area. It is then unlikely/impossible to close the path of ships.

8. Full loading at both ends of passenger or mail connections
This is deprecated for ships, but still applies to road vehicles and aircraft. Deliveries are always greater at one station than at the other, so full loading at both ends leads to lower transport efficiency and often to lower profits. In the case of road vehicles, the problem is that over time, a long line of vehicles waiting to be loaded always gathers at one end of the route, while thousands of passengers are waiting at the other station. I believe that it is better if full loading applies only to one of the stations, the one with more supplies, while in the case of the second one, instead of full loading, you can specify a waiting time, e.g. 5/10 days. The lines can be verified and if the delivery volumes change, the AI can change the station at which full loading is used, while the waiting time at the second one can always be, for example, 80% of the waiting time at the first one.
Edit: 14.0 almost kills this problem thanks to unbunch function - it's worth using.

9. Unwise use of transfer
Transfer is not a bad solution, but what matters is the direction in which it takes place. If it is in the opposite direction to the main transport direction from the collecting station, it will reduce profits by reducing the actual distance while increasing transport time. For the same reason, I'm also not convinced about multiple transfers (A>B, B>C, C>D, D>Z). A solution may be to determine the sum of the distances using transfer relative to the direct connection: AI should refrain from building such combined connections where the sum is more than, for example, 130% of the direct connection (A-B+B-Z < A-Z x130%). Another problem with the transfer concerns the too short distance between stops in the city - it makes no sense for an additional stop to take the load of the main station. The distances between stops should be greater and the ranges of stations should not overlap.
If these short transfers are for the development of the city (number of stops served), a better solution, at least in economic terms, is to build 2 or 4 separate stops just for the mail, somewhere on the outskirts of the city, so that they don't take up too much of the main line. Alternatively, it is worth over time, as the city grows, move these transfer stops beyond the reach of the main station.

10. Connecting one station to many others (Cargodist)
Such mergers are more realistic, but are usually more or less bad for the economy. More rather than less here. There are two main problems. The first is to use full load orders. This is definitely a bad solution. In this way, vehicles can wait several hundred days for loading. This requires a different approach. Instead of being fully loaded, vehicles should visit the station at regular intervals. It was quite a big problem before 14.0. This will soon be solved easily, but the second problem remains: chaotic geometry of the connections. Very often, two neighboring large cities (A and B) are connected by another small and distant city (C). In this way, the transport time increases significantly (A-C + C-B), but the distance remains small (A-B). I have no idea how to solve this. The only good and simple solution I see is to build separated A-B-C-D connections. This type of connections usually do not require excessive spread of stations and often generate income that is not worse than long-distance A-B lines, and they also look more interesting. Adding more stations may be a better solution than constantly moving the final station further and further away.

11. Twisted logic in the settings
Enabling an option disables it, but elsewhere you have to disable something for it to be enabled. If the option is enabled, something is unavailable and must be disabled to make it available. Green color sometimes means that something is disabled which means it is enabled and other times that it is unavailable. This twisted logic applies to many add-ons and is even present in the settings of the game itself. It's not something particularly important, but considering the number of options in the game, it would be nicer if the player didn't have to wonder what he's actually doing every time. Also, while testing the AI in many ways and changing the settings many times, I confused the meaning of these colors several times. To be honest, I have already written this suggestion in the case of few add-ons. ;)

12. AI starts by building a train depot...
...instead of building a headquarters. :) However, he never builds a headquarters and never removes a depot that he does not use. It's a detail, but it's nice if you can see the company's headquarters and judge it by the size of the building. The HQ location may also determine the main or initial region in which the AI will operate.

13. Company and president's names
Something basically unimportant, but the game looks more interesting when the AIs have some original names. This is the case with DictatorAI and SimpleAI, for example. Currently, only the first AI has the name of the president. This could depend on the AI's attitude. For example, the hostile/aggressive one could have the names of known bad people, and the friendly one could have the names of people with positive perceptions. They may also be misspelled names, e.g. Eleanor Mask, Bill Doors, Albert Zweistein, etc. In each case, it is good if, despite the different names, it was easy to recognize what kind of AI it is, e.g. Townsville Transport (AAAHogEx).
Attachments
Competition between companies - settings comparison.png
(176.59 KiB) Not downloaded yet
1. General.zip
(4.02 MiB) Downloaded 18 times
I am sorry for may English. I know is bed.
LaChupacabra
Route Supervisor
Route Supervisor
Posts: 391
Joined: 08 Nov 2019 23:54

Re: [AI] AAAHogEx

Post by LaChupacabra »

Water transport (2/5)

1. Spamming by buoys, shipyards and docks
This was the second biggest problem for me. The AI placed them recklessly and never tried to use existing ones. It looked very bad or even terrible when someone wanted to play with labels turned on (this is the default setting in the game). Fortunately, the problem of too many buoys will soon be almost obsolete. Almost, because the AI still uses them near locks and shipyards. In the case of locks, I don't see much point in using them - in practice, they don't secure anything. In the case of shipyards, this should also be unnecessary and I believe that they are the wrong way to solve the real problem which is still shipyard spam. AI builds them without reconnaissance of the terrain, often in ways that can block other ports, shipyards and locks. There was even a problem reported on Github related to the unwise construction of the shipyard. In the case of other AIs, e.g. ShipAI, they try to use existing infrastructure. They do not build separate shipyards and ports for each connection, but use existing ones nearby. This not only looks better, but is often more effective. It is also important that AI does not build shipyards directly next to anyone's ports, locks or other shipyards. An exception may be when the new shipyard only touches another player's shipyard sideways. This will avoid blocking your own or someone else's ports and routes.
[+] Spoiler
Image

2. Raising the land to build a port
I don't know if this is still an issue, but previously the setting to prevent this didn't work, and just lifting the land often led to a blocked waterway or port.
[+] Spoiler
Avoid removing water doesn't work.png
Avoid removing water doesn't work.png (185.55 KiB) Viewed 1152 times

3. Construction of an excessive number of canals
The situation is similar to that in the case of roads, where AI, instead of trying to use existing routes, always builds new ones, even in parallel, right next to the existing one.

4. Repeating the attempt to build the port many times
I noticed this situation in previous versions. It wasn't particularly common, but it looked strange when the AI repeatedly built and removed a port in the same place over and over again, endlessly.
Another problem is the repeated attempts to build a port on land. The AI builds a port, then gives up on it and builds somewhere else, then gives up again. It does this repeatedly and does not remove channels or raised/lowered terrain from previous attempts - this looks bad and is often disturb because these AI-owned canals are unremovable. First of all, I think AI gives up too quickly. But if he does resign, he should clean up after himself.

5. Canals built along the waterfront
Many times I have seen how AI, instead of trying to use existing waterways, builds a canal, which is often not even a shorter route, and in addition often limits the speed of ships. If possible, I believe that when routing, the canal should be penalized more and locks should be penalized even more. AI should also take into account the current cost of building such a canal, although this should not be the sole determinant of the route cost.

6. Use of ships of inappropriate capacity
Usually this looks good, but I have often seen the AI use ships that are much too small or much too big in relation to the cargo available and generated at the station. I think a good solution would be for the AI to use ships with a capacity of between 0.5x and 2x the monthly supplies. If he takes cargo from more than one station, he should take into account the one with a larger supply. It would be good if AI monitored situations, preferably creating stories from the last few months. To ensure that ships are not replaced too frequently, there should be some tolerance in the capacity/supply ratio.

7. Canals built in depressions
This is not a defect. I just wanted to write that I like it. It looks more natural. :)
Perhaps only the construction of the canal itself at sea level is unnecessary. Normally, these canals are expensive to build, ships move slower through them, and they also generate maintenance costs. I suppose it could have been due to the long time it took for the channels to fill, but maybe also due to a better appearance, or the inability of other companies to close the channel? I don't know which is better. I think 1001-1000 wins the seawater option for me.
Attachments
Spam of buoys, shipyards & docks.jpg
(191.06 KiB) Not downloaded yet
2. Water transport.zip
(9.3 MiB) Downloaded 18 times
I am sorry for may English. I know is bed.
LaChupacabra
Route Supervisor
Route Supervisor
Posts: 391
Joined: 08 Nov 2019 23:54

Re: [AI] AAAHogEx

Post by LaChupacabra »

Air Transport (3/5)

1. Too many airports
Instead of using the capacity of an existing airport, which is often served by only two planes, AI regularly builds another one right next to it. He also doesn't pay any attention to the existence of another company near the airport. When the limit on the number of airports is turned off, the map is literally spammed with them. If he can, he can build 8 large airports for one minimal production company, each of which will be served by just two planes.
I believe that here, as in the case of other types of transport, there should be a limitation in the form of a minimum distance between airports, which should not be closer to each other than 20 or even 30 tiles. To be able to serve the industry, an exception could be an airport intended only for loading, which could be built much closer. If AI wants to deliver raw materials to the company from several directions, it should first check whether it can use an existing airport for unloading.
[+] Spoiler
Too many airports.png
Too many airports.png (317.98 KiB) Viewed 1151 times

2. Wrong choice of airport size
This looks a bit strange, because small airports are used to transport passengers, who usually number a lot, while for the transport of industrial cargo, which is often delivered in small quantities, AI builds large international or even intercontinental airports, which are served by only two, often small planes or even airships.
The size of the airport should be adapted to the amount of available resources and the size of the aircraft that are to serve the connection. A sensible solution may be to purchase the land around the airport in case it needs to be expanded. Here, instead of the rather ugly and expensive purchase of land, the AI could use any of the objects if they are available.
If the connection is to be served by helicopters or blimps, AI should build low-maintenance landing pads instead of large and expensive airports.
[+] Spoiler
Wrong choice of airport size.png
Wrong choice of airport size.png (211.74 KiB) Viewed 1151 times

3. Not removing unused airports
AI usually does this, but only after a long time, or often never does it, and eventually goes bankrupt due to the costs of maintaining the infrastructure. If AI sells the last plane that connected airports, then those airports should be removed immediately. The eventual cost of re-building will usually be much less than the months or years of maintaining it.

4. Air connections to several destinations from one airport
Unfortunately, that's not a good thing in this game. It may add realism, but it also significantly reduces throughput and revenue when cargodist is enabled. This is even more unwise when a full load is used even at one end of the connection.

5. No station label effect
This is a game mechanics problem, but it's worth considering, especially in the case of airports (and train stations). If the airport is built on the north or east side, it will not affect the development of the city because the station label will be away from the city's buildings. This can be compensated by first building a stop in the city, then building an airport assigned to this stop and removing the stop - the label will be closer to the city. Alternatively, you can build a small connection for mail transport in the city, thanks to which the city will develop.

6. Excess mail at airports
Usually, for this purpose, I add one or several planes carrying only mail - on average, every tenth passenger plane. They don't have a full load at any of the airports, only a limited loading time. They just fly free and take excess mail. Usually, these planes make the most money, so it's probably a good solution. ;)
Unbunch is unlikely to be a good option for small and medium-sized airports. On these large ones, I think it might be worth using this to maintain spacing between free-flying planes if there were more than one of them.

7. Transport of bulk cargo
This is a bit of an oddity, which is not due to the underdevelopment of the AI, but to problems with the balance of the game itself, and partly also with the balance of sets with planes. Transporting coal or sand by plane shouldn't be profitable, but it is. It's a matter of common sense, but I think it would be good if AI used planes to transport coal and other such cargo as a last resort.
Attachments
3. Air transport.zip
(9.5 MiB) Downloaded 19 times
I am sorry for may English. I know is bed.
LaChupacabra
Route Supervisor
Route Supervisor
Posts: 391
Joined: 08 Nov 2019 23:54

Re: [AI] AAAHogEx

Post by LaChupacabra »

Road transport (4/5)

1. Spamming by roads
This is the biggest problem related to road transport. 40-70% of the roads that AI builds are simply unnecessary and all it does is make a big mess on the map that looks terrible and makes it difficult for others to build. First of all, even the largest number of roads will not prevent huge traffic jams - this is mainly a problem of the pathfinder, which does not see the traffic jams at all, but also the style of the stops you use and the excess of vehicles on the connections.
Example situation:
A huge traffic jam that is constantly growing (later reduced by AI) and a huge excess of roads to choose from one next to the other, which does not help at all, because the pathfinder directs all vehicles to one and the same road.
[+] Spoiler
Image
Yes, it's mainly a game problem. A possible solution would be road waypoints, which would allow for proper direction and distribution of traffic, but they are currently unavailable in the regular version of the game. An alternative solution may be to use stops for this purpose (Go non-stop via), but this will not be good if there is a city nearby (an unserved station will lower its rating, which will lead to the inability to build new stations over time). Additionally, spamming stop labels could be a problem. It may also make sense to build separate roads for slower trucks and separate roads for faster buses. It may even look interesting, especially if they do not connect to each other (bridges instead of intersections). But in general, I think AI should try to use existing paths. Not always, not by force, but if the extension of the route is insignificant, he should use what is available - this is what many AI do and it looks much much better.

2. Spamming by stops and depots
This is probably a new problem. AI builds too large and sometimes ridiculous numbers of stops and depots around one enterprise, which makes absolutely no sense. In one case, three AIs built over 70 stations and 150 (!) depots around one enterprise - of which only a few were partially occupied. There was no justification for this. It looked as if the AI was bored and added new elements from time to time. It was an extreme situation, but there is an excess of these stops and depots everywhere. I believe that the number of loading stops should be adequate to the production volume and probably no more than 2-3 due to limited road capacity. In the case of unloading stops, AI could try to unload cargoes from several directions at one station.
[+] Spoiler
Image

3. Problematic arrangement of stops
The current AI system has three drawbacks:
1. It can and often initiates traffic jams - apart from the excess of vehicles, it is their main cause
2. Vehicles waiting to load products can and sometimes do block the possibility of unloading raw materials
3. They occupy a proportionally large area and, as numerous separate stations, spam the map with labels.
Their main problem is that vehicles waiting to be loaded often wait on roads where other vehicles drive, which often causes them to block traffic on these roads. This is the problem with most AIs. However, this can be easily prevented by driving vehicles to a depot next to the station before loading. This way, any excess waiting vehicles will be hidden in the workshop and no one will obstruct the roads. It is important that the location of the depot and the vehicles leaving it do not block those that want to leave the station. It is also worth considering a layout that will take into account expanding the station instead of creating a new one. AI could reserve land for station expansion, or it could simply build slightly larger stations with 2-3 stops from scratch.
Below are some proven solutions. For the passenger line this is still valid, although the new unbunch function seems to be completely sufficient, and in the case of shorter vehicles it is the only effective one.
It would be good if AI did not mark new routes through stops. Perhaps it would be helpful to use a separate type of road for stations for this purpose.

4. Excessive number of vehicles
This is also one of the causes of traffic jams. AI should know the maximum number of vehicles for a given connection. Currently, when AI sees that the station's rating is dropping, it buys another and another vehicle, but this makes no sense, because these vehicles are probably already stuck in a traffic jam somewhere and by buying new ones, it only increases this traffic jam. The vehicle limit, even if it made it impossible to transport everything, would significantly reduce the risk of traffic jams.

5. Removing roads
This will never be good until it will not by possible to build private roads in this game like it is possible to build tracks. If AI doesn't build too many roads, it won't have to remove them either. Removing them, especially when a player is using them, can only be frustrating. Moreover, even when the AI builds these roads only for itself, once they are removed, it is very common to see numerous vehicles trapped on the remaining sections.
However, if the AI were to clear its own roads, it should do so step by step in one direction so that vehicles can leave the road.

6. Using the "wrong" types of roads and not improving them
AI often builds slow roads, often with a limit lower than the speed of vehicles traveling on them. Sometimes, although it doesn't always look interesting, it doesn't make economic sense. Possible short access roads from farms may make sense due to their appearance, but not long connections. As vehicles become faster and faster, AI, despite replacing them, doesn't improve its own roads, which even significantly reduces profits. AI should also avoid building roads near cities that prevent buildings from being built.

7. Building roads through mountains instead of tunnels or around them
Sometimes the AI can build tunnels, but much more often it creates somewhat irrational routes through the mountaintops. In this respect, the game itself has a good algorithm, which usually selects the places where the tunnel should be built very accurately.

8. Ugly little jumps and holes on the route
In the case of railway routes, AI smoothes them efficiently, even over longer distances. Here the AI doesn't do that at all. He could at least eliminate these small imperfections, because they are the ones that bother the eyes the most.

9. The routes are a bit too long
It's generally good that AI creates longer routes, but often they are simply too long and not very profitable. Moreover, long routes require more vehicles, which increases the load on the game. In most cases, the most profitable are distances lasting c.a. 100 days (not tiles), sometimes 200 (e.g. coal and other bulk cargoes in FIRS). It is worth taking into account both the speed of currently available vehicles and the highest speed that will be available, or for simplicity, 100 km/h. If possible, it is worth taking into account the cargo aging parameter, which may vary and may significantly change the most profitable distance (e.g. buses in Polroad and eGRVTS use this indicator).

10. Road layout taking into account the street grid
No AI do this. This is something that could improve the appearance of cities that absorb existing roads as they grow. This is not a problem if it is the original layout or "improved roads", but in the case of a 2x2 or 3x3 grid these additional roads don't look the best. If the AI optionally tried to build according to the grid whenever possible, it could improve the game image. Nothing special, but it would be a nice detail.
Attachments
Spam of roads (2).png
(589.66 KiB) Not downloaded yet
Spamming by stops and depots.png
(1.48 MiB) Not downloaded yet
4. Road transport.zip
(14.15 MiB) Downloaded 17 times
I am sorry for may English. I know is bed.
LaChupacabra
Route Supervisor
Route Supervisor
Posts: 391
Joined: 08 Nov 2019 23:54

Re: [AI] AAAHogEx

Post by LaChupacabra »

Railway transport (5/5)

1. Self-destructive construction of new connections by removing existing tracks and even part of stations
I noticed this problem about a year ago (probably version 52). I don't know if this has been fixed. This is most likely related to the AI crashing and appears only after restarting the saved game (previously the AI practically didn't crash at all). The AI works again, but behaves as if it had not seen the previously built routes and by building new ones it destroys the existing ones by interrupting them. It often builds new routes even through existing stations. The effect is that after some time most of the connections are destroyed.

2. Building the fastest tracks without taking into account maintenance costs
AI always tries to build the fastest type of track, which makes no sense when wagons have speed limits and infrastructure maintenance costs are taken into account. Why should AI use express train tracks that are several times more expensive to maintain, if, for example, coal wagons cannot travel faster than 120 km/h? Usually, maintenance costs are not very significant, but after many years of gaming they can constitute even more than 50% of revenues, so it would be good if the AI took this into account and adapted the tracks to the trains currently running on them. Economics aside, slow trains running on express rail tracks just look weird. ;)
[+] Spoiler
Build always the fastest tracks.png
Build always the fastest tracks.png (266.34 KiB) Viewed 1149 times

3. Choosing slow trains even though much faster ones are available
Even though the AI often tries to build the fastest possible tracks without any sense, it chooses trains rather in the middle of the pack. It doesn't look bad in terms of realism. The variety of choices often looks interesting, but in terms of competition it makes little sense. Why doesn't the AI for a long route choose a fast EMU and instead take a locomotive with medium speed cars? I've also never seen an AI build a maglev railway from a 2CC set or a Vactrain railway. AI also has a problem with the overuse of the Narrow Gauge 600mm set, where there are side trains dedicated to short and lightly loaded connections. Meanwhile, AI uses them for long-distance transport, which makes no sense at a speed of 8 km/h.

4. Routes leading through mountain peaks, too frequent sharp turns, routes running through the middle of the lake
Sometimes it's difficult to completely avoid mountains or to route the track in gentle curves, but often the route the AI takes seems quite irrational: a winding route over the top of the mountain, instead of a shorter and straighter route around it; a winding route, through the middle of the lake, instead of a straight one, around it. I don't know how it works, but I imagine that when planning a route, various obstacles (climbs, turns, etc.) are given penalty points and the most advantageous route is chosen. I think that the AI builds very quickly anyway, so it could devote more time to choosing better routes, avoiding an excessive number of turns and climbs, especially in close proximity to each other. A route that doesn't use bridges, even if it is slightly longer, should also be rated higher. For example, if a driveway has a -100 penalty, 1 bridge tile could have a -40 penalty. This will ensure that the bridge is used where it makes sense and looks good. By the way, the AI hardly uses tunnels at all to skip hills.
[+] Spoiler
Image

5. Too long stations
Personally, I often play with the maximum limit of 64 tiles and I find that the AI overuses this option. He often builds a station that is over 30 tiles long, which has no relation to the level of production or even the length of the trains that these stations serve. Yes, it happens that over time production will increase and using longer trains will make sense, but 30 tiles is rather excessive and in most situations it simply looks strange. Moreover, if vehicle breakdowns are enabled, a very long train takes a long time to enter and leave the depot, which significantly extends transport time and reduces throughput. It is also worth taking into account that the loading time is also the transport time and if a long train takes several hundred days to load, the final profit may be very small.

6. Speed without power is nothing
It seems that the AI pays little attention to power when selecting a locomotive and rather completely ignores the tractive effort parameter. I admit that in the case of some sets, choosing a locomotive can be a challenge and creating an algorithm that would accurately select the best option given so many variables may be troublesome. :) But anyway, I think some changes would be nice. If wagons for carrying a selected cargo are limited to, for example, 120 km/h, locomotives with higher speeds shouldn't therefore receive a higher rating. If the AI is able to determine the expected speed and weight of the load, it should then determine the minimum and expected power and tractive effort.

7. Freight stations for passengers?
The AI is pretty good at dealing with ISR stations, but using a freight station for passengers doesn't look great. ;) It's better if the AI uses standard stations for this. Kamnet's survey shows that Dutch Station, CHIPS and Japan Station sets are also popular. I think it would be worth teaching AI how to use these stations. In the case of the CHIPS set, this should be simple.

8. Bridges and tunnels too long
I partially understand the reason why they are at least 8 and often even 15 tiles long, but I don't find it particularly necessary or pretty. Yes, it is sometimes annoying when the AI closes your line with short bridges, which you were planning to expand, but it doesn't change much, because the player will have to adapt to what the AI did anyway. Usually it's not difficult. Meanwhile, such strangely elongated bridges and tunnels don't look very good. In addition, they may reduce line capacity.

9. Extending the passenger line
If AI were to build not only efficiently, but also more realistically, in the case of a passenger line, the final station could become an intermediate station. Then such a line could connect many cities. It would also be possible to create branches and create a more extensive network. With cargodist on, it may not be economically advantageous to connect lines, but I think that with the advantage AAA has, it wouldn't be a bad thing. Some time ago, for one of the discussion on Github, I created such a network connecting many cities. In the case of the network, it was labor-intensive and economically moderately effective, but if AI did something like that, it could be quite interesting. In the case of line extensions, this proved more profitable than one long (very long) line.

10. Servicing
I like double depots idea, I use this solution often and it works really well. However, the problem is their placement. Usually they are placed too sparsely (only one in both directions, on the entire, quite long line), and sometimes they are too dense. Usually, the first failures occur 80-100 days after the last service. This almost never happens more often and the level of default reliability (unless the vehicle is old) has no bearing here. It is worth placing depots at such a distance that the time between services is not more than 100 days and not less than 60-70. If the line is quite long, it is good to place the first depots right after leaving the station (not too close) at both ends of the route and possibly one/several additional ones somewhere in the middle of the route. If the route is short, it makes sense to place one depot just before the station. In the case of passenger and freight terminal stations, a good solution may be servicing between unloading and loading "unload > go to nearest depot / go to waypoint (if double depot) > load"

11. Single-track lines
This is a good solution for games with high costs, but too long lines lower the rating in the city and may lead to the closure of a mine or farm. I think that such a single-track line could be expanded into a double-track line over time. This may be two stages, where first a section for two trains to pass each other is built, and then the entire second track is built. The third stage could also be the expansion of the stations themselves.

99. Saving data in the form of signs
I don't know if the AI can save any information in the save file, so I don't know if it makes sense. :) Assuming it can't, perhaps a solution to recording the most important ones would be inscriptions on the map? Too much won't fit (?), but since yit is possible to put many inscriptions on one tile, placing them in the corner of the map shouldn't interfere with the game, and maybe there was some use for it.

I think that's all :)
Attachments
Not the best routes.png
(394.85 KiB) Not downloaded yet
5. Railway transport.zip
(13.08 MiB) Downloaded 20 times
I am sorry for may English. I know is bed.
User avatar
Redirect Left
Tycoon
Tycoon
Posts: 7249
Joined: 22 Jan 2005 19:31
Location: Wakefield, West Yorkshire

Re: [AI] AAAHogEx

Post by Redirect Left »

LaChupacabra wrote: 26 Mar 2024 19:28 a lot of text lived here, that doesn't need duplicating to scroll peoples fingers to the boneMost o
Most of these (in post 5/5) I don't see in the AI tests i do, possibly because of using vanilla settings & no GRFs.

Here's the main issues i come across when doing the tests.
But its pathfinding is interesting to say the least (see attachment) at times for sure. It also has issues where it buys lots & lots of profitable vehicles, and it may jam up the network with them, and if the jam occurs where the depot is so nothing can get in, it just sits there with that jammed network, rather than building another depot somewhere to use as overflow to get a handle on things. Other AI do this, and sometimes far worse, but AAA does it infrequently.
It also builds entirely new routes, even if the route is for the most part right next to another set of tracks. It often misses the cheaper option to just partially use the other set of tracks and make a junction up stream. It might be a difficulty in AI working that out though, rather than AAA specifically.

It also really likes buoys. I get it, they help with wayfinding. But wow, there's so many of them in such a small area. I haven't witnessed it building any, so I dunno if its just not reusing other buoys from other boat routes nearby, or if its just going all out and building lots so close for same routes, again see attachment for that.

It also really really really likes to steal goods at factories and other such, which is annoying. But its how you get such a competitive player, I guess? With it being AIs only in my test setups, its not a big deal, but i can see an actual player getting frustrated. If the AI was contributing to the goods it produces, that's better. But it sometimes steal outright and doesn't provide any raw resources to have any claim over the output.

Despite these issues i run into with it, it really is a difficult AI to beat, even when it is tripping over itself, no other AI ever beat it. In all of my testing, i would rate it a 10/10 on the competitive scale, if you wanna have the chance of actually losing in terms of profit? This is your goto AI, 100%.
Attachments
r1.png
r1.png (211.65 KiB) Viewed 1139 times
2024-03-26 19_59_09-OpenTTD 14.0-RC3.png
(336.88 KiB) Not downloaded yet
Image
Need some good tested AI? - Unofficial AI Tester, list of good stuff & thread is here.
AAAHogEx
Engineer
Engineer
Posts: 117
Joined: 30 Jan 2022 15:37
Location: Japan

Re: [AI] AAAHogEx

Post by AAAHogEx »

LaChupacabra wrote: 26 Mar 2024 19:25 Hey Rei :)

I've been writing this post for over a year now and I still haven't been able to publish it... There was supposed to be one short comment, but there was something else and something else. And it turned out that it would be best to approach it comprehensively, i.e. write even more. During this time, some of the comments have become outdated and I have to write some again. Okay, stop! I will post it as is.
First of all, I would like to write that you created a really impressive AI. This is the first AI that was able to cause me a problem in certain game configurations. Previously I considered ShipAI, trAIns and RailwAI as the most competitive, but now they have almost no chance against AAA. Only sometimes RailwAI can face it. You really raised the bar high. :) I like both his efficiency and even the style in which he builds. I like many of the solutions it uses, such as double depots when breakdowns are enabled, collision-free entry to stations, extending the range of stations or taking loads in both directions (or at least trying to do it). But, well, there are a few things that could be improved. :) You probably know about most of these problems, so these are not discoveries. Just a different perspective that might be useful. During this time, I collected some of these comments... ;) This will probably be one of the longest posts I have ever published anywhere. Just please don't take this as criticism or a to-do list. I apologize in advance for spamming so many comments at once. :wink:
Thank you so much for your passionate comment. :D I'm also delighted to see that you've done extensive research on this AI. I intend to reply to individual items in due course (I apologize, writing in English takes me quite some time). But as an overview, I think your points are mostly correct. The reasons for not addressing them are generally categorized as follows:

1. Unaware

OpenTTD has many settings and is even more multifunctional, and with the inclusion of NewGRFs, there really are a wide variety of ways to play (which I think is truly wonderful). Therefore, comprehensive testing is impossible by myself, and I'm very grateful for such reports.

2. Substantial Computational Time Required

For example, sharing resources falls into this category. Sharing roads requires searching for existing laid roads, which necessitates extensive map searches and results in a computational complexity of N squared. In contrast, simple shortest path calculations almost have no obstacles in normal, making the computational complexity N, indicating a different dimension in terms of time required for route finding. (The current version of AAAHogEx takes an approach of conducting route searches and reusing any pre-existing roads it happens to find.) But, an option that prioritizes aesthetics over competitiveness seems like it could be a good addition, considering the diverse ways to play.

3. Implementation Difficulties

Items that are difficult to implement have been postponed. Sometimes it is quite difficult to express in code, especially for functions related to aesthetics. For instance, whether an airport size fits aesthetically can be instantly determined by a human, but describing this in suitable algorithm is difficult. This is because it's hard to predict whether a logic put in place to avoid a certain case will work well in all other cases. However, I'd like to gradually work on these.

4. API Limitations

This often stems from the fact that human players can see a considerable amount of information from other companies, whereas AIs can hardly get any information about other companies (presumably to prevent the creation of hostile AI that interferes with the player's actions) . This frequently becomes an obstacle in creating friendly AIs. Being able to take a list of other companies' stations or vehicles would make it much easier to create friendly AIs. AIs don't even know if other companies' vehicles exist.
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 14 guests