[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

muppet9010
Engineer
Engineer
Posts: 6
Joined: 14 Jun 2022 13:48

Re: [AI] AAAHogEx

Post by muppet9010 »

Does the AI consider how much of an industry's resources are already being taken, or just the industries potential max production (regardless of how many companies are currently taking them) ?
I ask as am surprised how it often chooses to directly compete with me vs empty areas of the map that look to have approximate the same production rates and distances involved.

Really like the AI's strategy approach, transfer ideas and how it enlarges its routes over time. Did notice a few things that are less ideal below.

Also if you have multiple instances of this AI then they all seem to build exactly the same routes. Example is with 3 of the AI each set to start 30 days apart.
They each build between the same 2 towns and even after up and running they all made near 0 income. I restarted 2 of the AI's and they rebuilt between the same town again lol.
To kick start them I gave them a few hundred thousand each, but a year apart. The first built a coal line and then a year later the second built the exact same line that the first was servicing.

If you set the starting loan lower (£200,000 or lower) with medium costs and infrastructure cost enabled the AI's often run out of cash on their first build. Or they end up building a rubbish starting train as they are short of cash. They do seem to get their bus routes built in towns they pass and in a passenger city they are going to service. So it looks like they need to build all their stations (including passing towns) and track, then build their actual money making trains, then they can build their buses to maintain local authority reputation and to ferry passengers in the towns later once they have the proper cash starting to come in.

EDIT:
Here's the save for my post.
AAA Hog Ex.sav
(1.01 MiB) Downloaded 83 times
Danwell Coal - Where the red AI built first and then later the Green AI built the same line.
Sinnbridge - Passenger route they all started with and insisted they wanted to rebuild even when the AI was restarted. This is also the route the AI's initially spent soo much money on buses and other things they could only afford the most basic trains to start.
Last edited by muppet9010 on 16 Jun 2022 17:18, edited 1 time in total.
AAAHogEx
Engineer
Engineer
Posts: 117
Joined: 30 Jan 2022 15:37
Location: Japan

Re: [AI] AAAHogEx

Post by AAAHogEx »

muppet9010 wrote: 14 Jun 2022 13:57 Does the AI consider how much of an industry's resources are already being taken, or just the industries potential max production (regardless of how many companies are currently taking them) ?
I ask as am surprised how it often chooses to directly compete with me vs empty areas of the map that look to have approximate the same production rates and distances involved.

Really like the AI's strategy approach, transfer ideas and how it enlarges its routes over time. Did notice a few things that are less ideal below.

Also if you have multiple instances of this AI then they all seem to build exactly the same routes. Example is with 3 of the AI each set to start 30 days apart.
They each build between the same 2 towns and even after up and running they all made near 0 income. I restarted 2 of the AI's and they rebuilt between the same town again lol.
To kick start them I gave them a few hundred thousand each, but a year apart. The first built a coal line and then a year later the second built the exact same line that the first was servicing.

If you set the starting loan lower (£200,000 or lower) with medium costs and infrastructure cost enabled the AI's often run out of cash on their first build. Or they end up building a rubbish starting train as they are short of cash. They do seem to get their bus routes built in towns they pass and in a passenger city they are going to service. So it looks like they need to build all their stations (including passing towns) and track, then build their actual money making trains, then they can build their buses to maintain local authority reputation and to ferry passengers in the towns later once they have the proper cash starting to come in.

EDIT:
Here's the save for my post. AAA Hog Ex.sav
Danwell Coal - Where the red AI built first and then later the Green AI built the same line.
Sinnbridge - Passenger route they all started with and insisted they wanted to rebuild even when the AI was restarted. This is also the route the AI's initially spent soo much money on buses and other things they could only afford the most basic trains to start.
You have done a good job of discovering the weaknesses of this AI.

> Does the AI consider how much of an industry's resources are already being taken, or just the industries potential max production (regardless of how many companies are currently taking them) ?

No, it does not. The algorithm does not consider it for the following reasons

1. even if this AI develops a resource for which no one is competing, it will often be taken away from competitors in the end.
2. it takes a certain amount of computation time to determine how many competitors there are for every resource, and how much of the resource is available for transportation.

Furthermore, this AI does not use random functions as much as possible to check the correctness of the algorithm. This is to identify whether the result is correct by chance or if it has been calculated correctly.
Therefore, as you pointed out, there is a weakness that the AIs will compete with each other if you start several at the same time.

> If you set the starting loan lower (£200,000 or lower) with medium costs and infrastructure costs enabled the AI's often run out of cash on their first Or they end up building a rubbish starting train as they are short of cash. So it looks like they need to build all their stations (including passing towns) and track, then build their So it looks like they need to build all their stations (including passing towns) and track, then build their actual money making trains, then they can build their buses to maintain local authority reputation and to ferry passengers in the towns later once they have the proper cash starting to come in. have the proper cash starting to come in.

There is room for improvement here, too.
This will be a hint for future improvement. Thank you very much.
muppet9010
Engineer
Engineer
Posts: 6
Joined: 14 Jun 2022 13:48

Re: [AI] AAAHogEx

Post by muppet9010 »

thanks for the reply.

Yea it is certainly the nicest AI I have tried playing against as it develops its network in to greater profit over time and doesn't rely on spamming the map with just additional lines doing the same route in anywhere near the same frequency as many others :D
muppet9010
Engineer
Engineer
Posts: 6
Joined: 14 Jun 2022 13:48

Re: [AI] AAAHogEx

Post by muppet9010 »

BTW noticed the AI doesn't fully handle a ban on 90 degree turns.
90degree.PNG
90degree.PNG (470.05 KiB) Viewed 2538 times

also it seems to struggle with canals on the map. it sort of recognises them as being an issue, but then in trying to avoid them destroys them anyways.
canals.PNG
canals.PNG (698.26 KiB) Viewed 2538 times
The red line is where the canal was. The AI built up to it (the down and up track to sea level) and stopped as it couldn't afford to continue. When I returned it had done this.
Note the tracks covered in green where added later. It was just the 2 middle tracks being built at the time. With the double bridge track being built first and the bad tunnel track being built as the return track.
AAAHogEx
Engineer
Engineer
Posts: 117
Joined: 30 Jan 2022 15:37
Location: Japan

Re: [AI] AAAHogEx

Post by AAAHogEx »

Thank you for your accurate report.

Actually, I had noticed the problem itself, but had put it off because the solution seemed a little troublesome.
However, the fact that you are reporting it to me in this way means that the time has come for me to take action. :wink:
usane
Engineer
Engineer
Posts: 2
Joined: 07 Jun 2022 14:21

Re: [AI] AAAHogEx

Post by usane »

Hi,
I just started to play after a long brake and tried your AI. In early game it looked fine. Then i killed it and waited to appear again. In a later game, somewhere after 2010 had some issue.
First of all there are multiple AI of HogEx type at that time , and it is thinking a lot, because none of them has begun to build except the one was appeared aerlier, the AI #2. Second, thisr AI (#2) which built only 1 airpot (why only one?) and 2 bus and 2 truck stations is stopped doing anything after that until i needed to reload the game. When i reloaded my latest autosave it startedto build road wehicles. I don't know the other why don't start just yet, i don't remembre if the early game was or not more of your AI and all worked paralel or just one. I will test it again with more observatively.
hogexai_issue.png
(486.27 KiB) Not downloaded yet
AAAHogEx
Engineer
Engineer
Posts: 117
Joined: 30 Jan 2022 15:37
Location: Japan

Re: [AI] AAAHogEx

Post by AAAHogEx »

usane wrote: 09 Jul 2022 17:07 Hi,
I just started to play after a long brake and tried your AI. In early game it looked fine. Then i killed it and waited to appear again. In a later game, somewhere after 2010 had some issue.
First of all there are multiple AI of HogEx type at that time , and it is thinking a lot, because none of them has begun to build except the one was appeared aerlier, the AI #2. Second, thisr AI (#2) which built only 1 airpot (why only one?) and 2 bus and 2 truck stations is stopped doing anything after that until i needed to reload the game. When i reloaded my latest autosave it startedto build road wehicles. I don't know the other why don't start just yet, i don't remembre if the early game was or not more of your AI and all worked paralel or just one. I will test it again with more observatively.
hogexai_issue.png
From the screenshot, it looked like the AI created an Intercontinental Airport and ran out of money.
Thanks for finding the problem! :D
usane
Engineer
Engineer
Posts: 2
Joined: 07 Jun 2022 14:21

Re: [AI] AAAHogEx

Post by usane »

Noticed an other thing. THe AI place some train depos randomly on the map without aniything connected to it.
Like on the attached pic.
Attachments
depo1.png
(865.99 KiB) Not downloaded yet
AAAHogEx
Engineer
Engineer
Posts: 117
Joined: 30 Jan 2022 15:37
Location: Japan

Re: [AI] AAAHogEx

Post by AAAHogEx »

I've released a revised version based on recent reports. Thanks!

Version 19:

・Optimize behavior when budget is low
・FIX: Problem of running out of money due to expensive airport construction
・FIX: 90degree curves around a small station
・FIX: River destroyed by railroad tunnel in spite of setting 'Avoid removing water'

Enjoy!
AAAHogEx
Engineer
Engineer
Posts: 117
Joined: 30 Jan 2022 15:37
Location: Japan

Re: [AI] AAAHogEx

Post by AAAHogEx »

Version 20 released:

・Support: single-track railroad. (This AI can start with less 'Maximum initial loan')

Thanks!
RanFodar
Engineer
Engineer
Posts: 2
Joined: 15 Jul 2022 13:32

Re: [AI] AAAHogEx

Post by RanFodar »

The AI doubled the rail tracks made in 5 years and reached more towns and industry facilities. Great job, and please continue working on the "best all-rounder AI"! :] :] :]
AAAHogEx
Engineer
Engineer
Posts: 117
Joined: 30 Jan 2022 15:37
Location: Japan

Re: [AI] AAAHogEx

Post by AAAHogEx »

Thanks, RanFodar!

This modification makes the performance of the railroad too good to be good, so it is better to disable all except the railroad. :roll: I plan to improve the performance of non-railways.
AAAHogEx
Engineer
Engineer
Posts: 117
Joined: 30 Jan 2022 15:37
Location: Japan

Re: [AI] AAAHogEx

Post by AAAHogEx »

Version 22 released!

・Improve performance of road vehicles
・FIX: inefficiencies in multi-cargos wagons composition
・Other minor bug fixes

Road vehicles only. Vanilla (profile:Hard / initial load:200k / max road vehicles:1000 / 512x512)
ss 2022-07-18 140830.png
(161.29 KiB) Not downloaded yet
Kjell291
Engineer
Engineer
Posts: 3
Joined: 18 Jul 2022 12:48

Re: [AI] AAAHogEx

Post by Kjell291 »

I get this error
OpenTTD.png
(94.85 KiB) Not downloaded yet
AAAHogEx
Engineer
Engineer
Posts: 117
Joined: 30 Jan 2022 15:37
Location: Japan

Re: [AI] AAAHogEx

Post by AAAHogEx »

Kjell291 wrote: 18 Jul 2022 12:52 I get this error
OpenTTD.png
Thanks for the report.

The logs suggested the presence of a ship with zero capacity or failure to refit. Can you tell me what newgrfs you are using?
AAAHogEx
Engineer
Engineer
Posts: 117
Joined: 30 Jan 2022 15:37
Location: Japan

Re: [AI] AAAHogEx

Post by AAAHogEx »

AAAHogEx wrote: 18 Jul 2022 17:54
Kjell291 wrote: 18 Jul 2022 12:52 I get this error
OpenTTD.png
Thanks for the report.

The logs suggested the presence of a ship with zero capacity or failure to refit. Can you tell me what newgrfs you are using?

Well, I've put the corrected version up on Bananas as v23, so here's a look at it.

・FIX: crash due to zero vehicle capacity
・FIX: articulated road vehilces estimate failure
muppet9010
Engineer
Engineer
Posts: 6
Joined: 14 Jun 2022 13:48

Re: [AI] AAAHogEx

Post by muppet9010 »

the latest versions certainly play a much better game from a low money start :)

I did notice that at a point it removes its early single track routes. It had 5~ routes and I saw it removed the trains from all 5 and fully removed the track from one of them, but the other 4 it left the track and stations for years afterwards.
Not the biggest issue, but it does cause some clutter on the map and with high infrastructure maintenance costs it is technically wasting money on them.
What was odd to me was that it removed the single lane routes, but didn't then replace them with dual lane routes and instead built other routes. I'd have assumed it only removed its old train and track when it planned to build a dual track replacement for them.
muppet9010
Engineer
Engineer
Posts: 6
Joined: 14 Jun 2022 13:48

Re: [AI] AAAHogEx

Post by muppet9010 »

Something weird is happening with the AI: it seems to be aggressively dismantling its train networks and sometimes replacing them with long distance road vehicles.

I left the AI running in fast mode and noticed that after after it got rid of its single line tracks it seemed to carry on getting rid of other dual track lines which should have been profitable, i.e. no competition on the medium to long distance routes.
In some cases it seems to have replaced them with very long distance road vehicle routes.

This can be seen by its train numbers when it had ay 130-140 numbered trains, but just under 100 were actively running at a point.

Save is attached a while after I noticed this. But its operating profit dropped 75% over a few years in the graph it was doing this (may be too far back to see now).
Attachments
AAA Hog Ex.sav
(683.24 KiB) Downloaded 71 times
Kjell291
Engineer
Engineer
Posts: 3
Joined: 18 Jul 2022 12:48

Re: [AI] AAAHogEx

Post by Kjell291 »

AAAHogEx wrote: 18 Jul 2022 17:54
Kjell291 wrote: 18 Jul 2022 12:52 I get this error
OpenTTD.png
Thanks for the report.

The logs suggested the presence of a ship with zero capacity or failure to refit. Can you tell me what newgrfs you are using?
I loaded FIRS, but forgot to enable a compatible boat newgrf, I think this caused the issue.

I noticed the AI does not use Chips stations, could this be added as a feature in the future?

And I just wanted to say that this is by far the best AI I have ever tried!
AAAHogEx
Engineer
Engineer
Posts: 117
Joined: 30 Jan 2022 15:37
Location: Japan

Re: [AI] AAAHogEx

Post by AAAHogEx »

Hello muppet9010!

Thank you for the interesting report and saved data.

AAAHogEx deletes a line if it is loss‐making. However, the calculation of maintenance costs per distance for a single-track railroad is the same as for a double-track railroad. Therefore, this AI considers the maintenance cost of single-track railroads to be twice the actual cost, and single-track railroads may have been unnecessarily deleted.

Well, the fix would be easy since it would simply cut the maintenance cost of a single-track railroad in half.
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: Google Adsense [Bot] and 23 guests