Some of you may remember my previous attempt at an AI, CPU. Creating if was a fun experience, but the result was super buggy and didn't generate much profit, and generally did a lot of stupid stuff. Since then, I have learned a lot about programming in general, and decided to give it another try. Thus, I present to you snakeAI.
150,000 revenue in 3 years, 200,000 in 4, profit after 9 years
Works with most non-insane new-grf's (tested with several vehicle and industry sets)
Road vehicle only for now, usually reaches the limit after a couple of years
Only builds short-distance routes
Dynamically increases vehicle count when vehicles can't handle the supply
Vehicles get interesting names
There are probably still plenty of bugs, and I have a few features I still think I may be able to finish before my holiday ends. Please send me all your crashes, bugs, and general strange behavior. There might be some I can fix.
It's always good to see a new AI appearing.
However you might think about putting your AI online on bananas. Most people are too lazy to manually install an AI (including me). I think it will increase the chance of getting feedback. Good luck!
Thanks Xarick, should be fixed now. Other changes include slightly better loan management and some bug fixing in the station expanding routine.
Even though this AI is quite simple, there are still some code paths that are super annoying to debug since they are taken so rarely. Sometimes while testing it runs fine for 20 years before some feature I implemented a long time ago starts behaving weird.
New version, the most significant new feature is planes. Planes are built to form a network, where every airport should have connections to as many as possible different airports as it can handle. Snake can also upgrade airports and airplanes, though it rather often doesn't work for some unknown reason (ERR_UNKNOWN is so fun to debug).
Fixed bug where building a new station would sometimes infinite loop
RV's are also upgraded
Delete one RV when a 3 or more RV's are waiting for full load at a empty station, to avoid all vehicles from a station being sold for negative profit at the same time when it is actually still producing cargo
Introduced bug where Snake will continue to try and build routes after the vehicle limit has been passed
Actually use vehicle cost to estimate vehicle cost instead of the randomly chosen 10,000 pounds
Slightly more efficient loan management during pathfinding
Fixed multiple crashes related to upgrading airports
Snake does a better estimation of the number of vehicles initially needed, instead of just building 4
Turned out my system to delete vehicles with negative income broke at some point, but it's fixed now
Fixed strange behavior when close to the vehicle limit
Made airport blacklists clear every five years, so it can retry when new airports become available.
While I think I allready have a bit many high-res images for a thread, I have a really nice screenshot of testing the limits of my AI by putting 190+ busses on a short intercity route. Snake sold most of them after about 1.5 years, except some actually magically managed to make a profit:
@xairick Thanks for the report. That is indeed probably a bug, and I'll look into it.
Version 8. Turned out my vehicle upgrade system has become horribly broken at some point, resulting in lots of way too old vehicles running around, as well as lots of vehicles without orders. Fixed now.
Version 9. Will now (attempt to) delete level crossings after a train crash. In case of a crash, the AI will first:
Replace the vehicle
Send all vehicles with shared orders to the depot
Wait at least 50 time units, then 10 more until the level crossing can be removed
Recursively remove all dead ends owned by Snake in a 10 by 10 area around the crash site
re-pathfind the route of the crashed vehicle
Start all vehicles on the route again.
Fixed this after noticing Snake was spending excessive amounts of money replacing vehicles on busy level crossings. The system does not currently always work. When multiple lines are using the same level-crossing, only one is replaced. It also does not detect whether the crossing is owned by a other company, (I believe there is no API function for this) and will attempt to destroy it anyway.
Your AI performed great in the first years when starting up. See e.g. the grey line in the image I posted in the EmotionAI topic.
However as soon as SnakeAI reaches the vehicle limits you see many ERR_VEHICLE_TOO_MANY. It should try to improve its best routes in that case and get rid of under performing ones.
It probably also is a good idea to add a setting that defaults to off to allow building debug signs.