Leaking Freight - A freight AI

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
TTFTCUTS
Engineer
Engineer
Posts: 24
Joined: 15 Oct 2009 00:25

Leaking Freight - A freight AI

Post by TTFTCUTS »

Hi all,
I've been working on an AI on and off over the last week, and I think it's ready to let loose in the wild. Leaking Freight is a cargo runner AI which currently only uses trucks, though it will eventually use ships and trains too. It's pretty fast and can expand to completely cover all viable routes in a 512x512 map in about 15-20 years.
LeakingFreight-Map.png
512x512 map after ~30 years.
(53.19 KiB) Downloaded 2 times
Some features include:
  • Almost* full support for all road vehicle sets.
  • Support for alternate industry sets like FIRS and ECS (though it doesn't understand stockpile limits). It even avoids the seasonal ECS fruit farms.
  • Re-use of drop stations.
  • Attempted re-use of roads, though it isn't mad about this for speed reasons.
  • Intelligent picking of best vehicles based on cargo capacity, speed and the rate of cargo payment decay.
  • Calculation of route capacity so stations aren't overcrowded with vehicles (mostly).
  • Pretty strong competitor to the other AIs I tested with just trucks available.
  • Builds its evil corporate hideout in the mountains away from towns.
  • Super-serious not silly at all company president name generator with over half a million (514488) possible combinations!
Some things it can't do / Is bad at:
  • Adapting to interference when building (most of the time just dies or fails to build).
  • Playing nice with other instances of itself because it chooses the same routes a lot.
  • Anything more than very basic money awareness.
  • Keeping town councils happy.
* Since I haven't implemented the evil company testing labs yet, sets like the most recent BANDIT build result in assumed capacities being higher than they really are, leading to only about half the needed trucks being built per route. Same thing happens when refitting box trucks to FIRS supplies etc.
LeakingFreight-1.tar
(70.5 KiB) Downloaded 158 times
So, there you have it. Next on the list for development is trying to cope with something changing during pathfinding or construction, better money management and the capacity testing lab (currently just a depot stapled onto the HQ).

Any and all feedback welcome. More screenshots in next post.
Last edited by TTFTCUTS on 19 May 2012 20:33, edited 1 time in total.
TTFTCUTS
Engineer
Engineer
Posts: 24
Joined: 15 Oct 2009 00:25

Re: Leaking Freight - A freight AI

Post by TTFTCUTS »

Screenshots:
LeakingFreight-MachineShop.png
LeakingFreight-MachineShop.png (55.05 KiB) Viewed 3293 times
FIRS Machine shop showing dropoff and cargo-specific pickup stations.
LeakingFreight-MountainLair.png
LeakingFreight-MountainLair.png (77.8 KiB) Viewed 3293 times
Mountain lair HQs. Most of the time you will find Leaking Freight's HQ on high ground.
LeakingFreight-StationFail.png
LeakingFreight-StationFail.png (83.36 KiB) Viewed 3293 times
Multiple instances of Leaking Freight have trouble playing nice together...
User avatar
lawton27
Tycoon
Tycoon
Posts: 1418
Joined: 03 Aug 2009 14:29
Location: Manchester

Re: Leaking Freight - A freight AI

Post by lawton27 »

Looks like a very nice AI you've got here, I'm yet to test it out however. I think I saw discussed in another thread you could solve the issues of having multiple instances always building HQs and stations together by having it pick several good routes / locations and picking a random one to build rather than always the best :wink: .
Brumi
President
President
Posts: 921
Joined: 18 Jul 2009 17:54

Re: Leaking Freight - A freight AI

Post by Brumi »

Quite impressive :)

I'm testing it right now, and I have found one problem so far: With your current structure of orders, your vehicles don't get serviced at all, and that can be painful when breakdowns are enabled...
TTFTCUTS
Engineer
Engineer
Posts: 24
Joined: 15 Oct 2009 00:25

Re: Leaking Freight - A freight AI

Post by TTFTCUTS »

Ah, I wasn't aware that a go to depot order would override the automatic servicing behaviour of vehicles - I was more concerned with making sure that they got autoreplaced when breakdowns (and therefore servicing with the setting) were off. I'll add in a "service if needed" order before the conditional for next the next version, just try without breakdowns for now I guess :)
oxyk
Engineer
Engineer
Posts: 29
Joined: 04 May 2012 06:51
Location: ukraine

Re: Leaking Freight - A freight AI

Post by oxyk »

you don't need to send them to the depot in orders, it's a waste if breakups set to none. you can send them to depot with given command when you start upgrade or when you check that their max age goes to limit.

Code: Select all

AIVehicle.SendVehicleToDepotForServicing(v)
TTFTCUTS
Engineer
Engineer
Posts: 24
Joined: 15 Oct 2009 00:25

Re: Leaking Freight - A freight AI

Post by TTFTCUTS »

Actually there's an order type when using a go to depot order which is automatically skipped if they don't need a service (and is completely ignored when servicing is off).

In game it appears as "service at x". See here for the info on the AI order type.
oxyk
Engineer
Engineer
Posts: 29
Joined: 04 May 2012 06:51
Location: ukraine

Re: Leaking Freight - A freight AI

Post by oxyk »

thank you for the useful link, somehow i missed the whole page )
you said

"
I was more concerned with making sure that they got autoreplaced when breakdowns (and therefore servicing with the setting) were off.
"

i suggested fast solution how to send these vehicles to the depot when you need them to be there for upgrade. it's nothing to do with orders and it works with any settings.
TTFTCUTS
Engineer
Engineer
Posts: 24
Joined: 15 Oct 2009 00:25

Re: Leaking Freight - A freight AI

Post by TTFTCUTS »

Oh, sorry, I missed the point a bit there... Yeah, they are already sent to depot when a better vehicle type is found, provided the AI has enough money to actually do the replacement. Otherwise they keep going until orders tell them to visit the depot.
oxyk
Engineer
Engineer
Posts: 29
Joined: 04 May 2012 06:51
Location: ukraine

Re: Leaking Freight - A freight AI

Post by oxyk »

balme my awful english ) what i'm trying to say, is that you don't need to use depot orders in both breakdown settings. if breakdowns on, you have maintenance setting for vehicles to visit depots once they need maintenance (even if they don't have such orders in the list). and if there's no breakdowns, you can send them to the depot from AI when needed.
at the other hand, having just 2 stations in orders have benefit of being able to manipulate with obtained data from that orders (fast access to staion ids that vehicle belongs). but that's a matter of personal settings )
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 5 guests