[AI] HogNet

Discuss the new AI features ("NoAI") introduced into OpenTTD 0.7, allowing you to implement custom AIs, and the new Game Scripts available in OpenTTD 1.2 and higher.

Moderator: OpenTTD Developers

Post Reply
kakakul
Engineer
Engineer
Posts: 6
Joined: 25 May 2026 02:17

[AI] HogNet

Post by kakakul »

HogNet - An AI that build networks and makes use of CargoDist!

Overview
HogNet is a fork of AAAHogEx. The original AAAHogEx is designed to maximise profit — it builds point-to-point routes between towns and industries that earn the most money. HogNet changes the core objective: the AI tries to connect towns into a single large network, using a hub-and-spoke strategy. For industries, the AI tries to reuse infrastructure as much as possible, using a spine-and-branch strategy.

Pax and Mail Network Building
Hub and Spoke
The AI identifies the largest towns as major hubs to connect with high throughput connections. Smaller towns around each hub are then connected to the hubs. In this way, smaller towns can get connected to the larger network while still being profitable.

No isolated route clusters
In AAAHogEx, the AI may build profitable routes in completely separate parts of the map, resulting in disconnected islands of service. HogNet rejects any passenger or mail route that would form an isolated island — at least one endpoint of a new route must have a connection to the existing network. The whole map converges toward one unified transport system.

Feeder bus and truck routes within towns
When the AI builds a second station inside a town that already has a station, it now creates a short feeder service connecting the two stops within the town. This allows cargo and passengers to move between stations in the same town before being forwarded on longer-distance routes.

Freight Cargo Handling
Spine and Branch
The AI starts with a strong rail connection between a producing industry and an accepting industry, then expands from that line by adding new branches to nearby compatible producers. Instead of creating many isolated point-to-point freight lines, freight service grows outward from shared rail infrastructure, including a shared main line. Though once branches are exhausted, a new spine will be built.

Road feeders collect nearby cargo
If smaller or nearby industries can provide cargo accepted by the active freight destination, the AI can add road feeder routes into the freight rail station. These feeders help pull more cargo into the rail network without requiring every industry to get its own long-distance railway immediately.

Other Changes
Vehicle Buy/Sell Logic
Vehicle buy/selling logic had to be refactored to take into account transiting passengers from other nodes in the network.


Network Topology (Pax network on top, Freight network below)
Network Topology resize.jpg
Network Topology resize.jpg (118.04 KiB) Viewed 566 times
Competitiveness (about 20% profitability vs AAAHogEx, after 10 years)
Profitability resize.jpg
Profitability resize.jpg (103.85 KiB) Viewed 566 times


Install "AAAHogNet" via in-game content manager (Bananas)


Github repo: https://github.com/kakakul/AAAHogEx/tree/HogNet
Disclaimer: Portions of this codebase were generated or assisted by artificial intelligence tools (specifically Claude and GPT Codex).
Last edited by kakakul on 05 Jun 2026 15:41, edited 3 times in total.
kakakul
Engineer
Engineer
Posts: 6
Joined: 25 May 2026 02:17

Re: [AI] HogNet

Post by kakakul »

Changelog:

v4: First release!
User avatar
Redirect Left
Tycoon
Tycoon
Posts: 7590
Joined: 22 Jan 2005 19:31
Location: Wakefield, England

Re: [AI] HogNet

Post by Redirect Left »

Very interesting rework of the AAAHogEx AI here, I love it!

One thing though, I'm not sure what happened here in the upgrading routine. There are also stuck vehicles here, which got trapped by bad signal directions. Maybe the stuck trains confused the upgrading, i've no idea.
The savegame has been attached to this at the point of this screenshot being taken
AI STRENGTH TEST 141.sav
(1.82 MiB) Downloaded 6 times
Image

It also seems to have trouble with trains bumping into signals and jamming up portions of the network, and it doesn't attempt to resolve it when it comes up.
Screenshot 2026-05-27 030538.png
Screenshot 2026-05-27 030538.png (189.7 KiB) Viewed 772 times
Image
Need some good tested AI? - Unofficial AI Tester, list of good stuff & thread is here.
kakakul
Engineer
Engineer
Posts: 6
Joined: 25 May 2026 02:17

Re: [AI] HogNet

Post by kakakul »

Thanks for testing it out and providing the save file! I will have to disable train track upgrading for now as it is currently not possible to gracefully upgrade so much shared infrastructure between multiple lines. Bananas is currently not working (for a few days now), will update the AI when possible.

Btw, the AI does attempt to recover from lost trains in 3 ways:
1) Attempt to send train to existing depots
2) Scan nearby tracks for signals. If a signal is found in the wrong direction compared to other signals on the same track, then flip the offending signal
3) If still not resolved after 180 days, build depots in various locations near to the lost train and spam the send train to depot button

But the best is still to fix the root causes leading to lost trains, such as the botched track upgrading that you showed.
Last edited by kakakul on 29 May 2026 06:20, edited 1 time in total.
kakakul
Engineer
Engineer
Posts: 6
Joined: 25 May 2026 02:17

Re: [AI] HogNet

Post by kakakul »

I haven't been able to upload to Bananas in over a week, so I'll put the updated version here first. Version V6 comes with fixes for multiple different root causes of lost trains, including botched rail type upgrades.
Attachments
HogNet v6.zip
(318.87 KiB) Downloaded 11 times
kakakul
Engineer
Engineer
Posts: 6
Joined: 25 May 2026 02:17

Re: [AI] HogNet

Post by kakakul »

Just wanted to update that V6 has been uploaded to Bananas. Enjoy!
Mondieu_Colera
Engineer
Engineer
Posts: 1
Joined: 20 Jun 2026 19:04

Re: [AI] HogNet

Post by Mondieu_Colera »

Love the Ai. No idea how to post an image. It failed in same spot twice but not sure it can recover this time.
other note: Fails to build anything with Vac train GRF is loaded if thats helpful or not just says failed to place depot in water.
Attachments
AAAhognet.png
(2.45 MiB) Not downloaded yet
AAAhogNet Fail.sav
(1.41 MiB) Downloaded 4 times
kakakul
Engineer
Engineer
Posts: 6
Joined: 25 May 2026 02:17

Re: [AI] HogNet

Post by kakakul »

Glad you enjoyed it!

1) About the lost train, everything looks alright with the track, so I can only guess it was caused by station congestion. I have stopped the AI from buying trains when the station is congested and sell a train instead. Fixed that in V7 release.
2) About Vac train GRF, root cause was the AI trying to read train information from memory before it was loaded into memory. Fixed that in V7 release.

V7 has been uploaded to Bananas!
mwm0riarty
Engineer
Engineer
Posts: 3
Joined: 13 Jun 2025 02:15

Re: [AI] HogNet

Post by mwm0riarty »

I have tried using HogNet but never can get it to do anything with airplanes disabled. It would seem you have to give it all options, no restrictions for it to work.
Last edited by mwm0riarty on 13 Jul 2026 00:37, edited 1 time in total.
kakakul
Engineer
Engineer
Posts: 6
Joined: 25 May 2026 02:17

Re: [AI] HogNet

Post by kakakul »

mwm0riarty wrote: 12 Jul 2026 23:39 I have tried using HogNet but never can get it to do anything with airplanes disabled. It would seem you have to give it all options, no restrictions for it to work.
Sorry, just saw this as I didn't get a notification for this message ?(
I have tested (without any newGRFs or gamescripts) with airplanes disabled and HogNet is able to operate normally. Could you check if it is a newGRF issue?
An alternate possibility is a) if you play very high sea level or b) minimal/no industries or c) somehow costs are too high to build the first line.
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 0 guests