WormAI

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

Wormnest
Engineer
Engineer
Posts: 117
Joined: 14 Jul 2013 12:33
Location: Netherlands

Re: WormAI

Post by Wormnest »

And another update for WormAI fixing a few crashes and bugs and improving several things.

Changelog

Version 6, 2016-05-28
  • Fix: Crash when loading a savegame saved when building a rail route or when replacing trains.
  • Fix: Crash when we get loaded into a savegame without getting any saved data.
  • Fix: We need to make sure we have at least some money to build a rail route.
  • Fix: Make sure that the vehicle we share orders with is valid.
  • Fix: 90 degree turns near a passing lane.
  • Fix: border of map starts at 1,1 not 0,0. (We were not building airports in towns near the left and upper borders.)
  • Change: more checks before building a passing lane, we should see less land is sloped wrong messages.
  • Change: Improved airport upgrading.
  • Change: Better handling of airplane NewGRF's that have high prices.
  • Change: Rail pathfinding tweaks.
  • Change: Don't cancel and remove routes just because we don't have money for vehicles. Just add them later when we do have the money.
  • Change: Don't use airplanes that are hardly profitable.
  • Change: Blacklist airports that we failed to upgrade for a while.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: WormAI

Post by Zuu »

I find it interesting that one crossing made by your AI is using bridge and one is not. Is it by random or by the funds available? The road and rail pieces don't have built date, but stations do and it looks by the owner of roads/stations that the road was there first.

Other than that, or maybe thanks to that, your AI is in shared lead in the operating profit graph in my 14 AI test game. At year 1967 started from 1953.
Attachments
Jones & Co., 19th Sep 1967.png
(1.62 MiB) Not downloaded yet
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Wormnest
Engineer
Engineer
Posts: 117
Joined: 14 Jul 2013 12:33
Location: Netherlands

Re: WormAI

Post by Wormnest »

I had to check the code since it's almost a year since I worked on this but it seems that it depends on the pathfinder costs whether it chooses to build a bridge or not.
Besides that since WormAI doesn't yet do road transport I guess it doesn't really matter too much what it chooses. Especially if it's competing against other AI's it might be a strategy to lower competitor's profits.

For normal users it might be annoying so maybe I should add a setting to disallow building tracks across roads.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: WormAI

Post by Zuu »

Wormnest wrote:Especially if it's competing against other AI's it might be a strategy to lower competitor's profits.
Maybe I care too much about ethics, but I file that under unfair competition to on purpose use rail/road crossings to block road traffic. It is very hard for other AIs to do anything about it if they didn't build the road themselves. If it is my AI that built the road, I can (and do) replace it with a bridge when there is a bus/truck crash event, but if there is a fellow road AI that built the road and does not care about upgrading it to a bridge, then it is not so much I can do about it.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Wormnest
Engineer
Engineer
Posts: 117
Joined: 14 Jul 2013 12:33
Location: Netherlands

Re: WormAI

Post by Wormnest »

A new version of WormAI is available on bananas.
Only changes in aircraft handling this time. WormAI should now be better at handling the World Airliners Set and other NewGRF that have higher costs for large and longer range aircraft.

Changelog

Version 7, 2017-04-16
  • Fix: Not checking air route range at startup under certain conditions.
  • Change: Adjust maximum distance for air routes when we have limited money.
  • Change: Adjust aircraft selection when we have limited funds and high prices of longer range aircraft.
xarick
Transport Coordinator
Transport Coordinator
Posts: 336
Joined: 26 Feb 2015 00:52

Re: WormAI

Post by xarick »

WormAI v7 on OpenTTD 1.8.0


Too long to load error when loading a savegame
Attachments
Unnamed, 2057-01-11.png
(52.32 KiB) Not downloaded yet
Unnamed, 2056-10-03.sav
(10.35 MiB) Downloaded 179 times
Formerly known as Samu
Wormnest
Engineer
Engineer
Posts: 117
Joined: 14 Jul 2013 12:33
Location: Netherlands

Re: WormAI

Post by Wormnest »

xarick wrote:Too long to load error when loading a savegame
Thanks for the report.
Assuming this is the save that caused the error. Do you also have a savegame from a little earlier that does load or at least mapsize and rough estimate about number of vehicles.
xarick
Transport Coordinator
Transport Coordinator
Posts: 336
Joined: 26 Feb 2015 00:52

Re: WormAI

Post by xarick »

Sorry, I don't have. I saved it for the night and to continue on the next day. It was a one time save
Formerly known as Samu
xarick
Transport Coordinator
Transport Coordinator
Posts: 336
Joined: 26 Feb 2015 00:52

Re: WormAI

Post by xarick »

WormAI doing a bad clean up job and creating some roller coaster rail routes. Savegame attached. The settings are borrowed from server 7 of btpro, they're probably influencing some of the weird misbehaviours.

Image

Image
Attachments
Sem nome, 5 Mar 2003.png
(181.88 KiB) Not downloaded yet
Sem nome, 14 Out 2000.png
(135.43 KiB) Not downloaded yet
Sem nome, 27 Out 2000.sav
(161.38 KiB) Downloaded 187 times
Formerly known as Samu
Wormnest
Engineer
Engineer
Posts: 117
Joined: 14 Jul 2013 12:33
Location: Netherlands

Re: WormAI

Post by Wormnest »

A new version of WormAI is available on bananas.

The rollercoaster lines were caused by a pathfinding bug in the rail pathfinder, now fixed. Not deleting tracks was most likely caused by running out of money. This should be less likely to happen now because of using RemoveRailTrack instead of DemolishTile where possible.


Changelog
Version 8, 2019-09-09
  • Fix: Determination of 90 degree turn in rail pathfinder was wrong causing rollercoaster tracks and difficulties finding a path.
  • Fix: Remove rail tracks by using RemoveRailTrack as much as possible since that is cheaper than using DemolishTile which makes it less likely that we run out of money early in the game with a failed train route.
  • Fix: Not building airports in spots where the noise level will equal the maximum allowed noise level.
  • Fix: Take station spread setting into account when determining best airport type.
  • Add: Manage over saturated air routes by either removing planes from route or upgrading airports.
  • Add: Upgrade airports to International airports in certain cases.
  • Add: Regular checks that industries we use on a rail route are still accepting/producing our cargo. If not we will sell the vehicles and close the route.
  • Add: Extra pathfinding penalties to make it less likely the pathfinder continues a path far away from our destination.
  • Change: Improve finding airport spots adding towns to blacklist more often and only checking towns within distance limits.
  • Change: Adjust max aircraft route distance in early starting games depending on plane speed and reliability.
  • Change: Rail: Increase length of train routes if we have enough money.
  • Change: Lower minimum town for airport size in easy setting from 2500 to 1500.
  • Change: Use Graph.AyStar version 6 instead of version 4.
  • Change: Moved repository and issue tracker to Github.
Nakama
Engineer
Engineer
Posts: 1
Joined: 01 Jan 2022 23:10

BUG DETECTED ON 12.1 VERSION - AI'S

Post by Nakama »

GOOD NIGHT,

I WOULD LIKE TO REGISTRATE THAT A BUG AT AI'S LIBRARY CAN'T MAKE IT RUN CORRECTLY! SEE THE IMAGE link ABOVE:

https://imgur.com/a/jbGJXDt

I NEED HELP TO MAKE IT RUN FOR FUN. ALL AI'S HAVE ERROR BUT TERRON WORK'S GREAT.

NAKA.
Wormnest
Engineer
Engineer
Posts: 117
Joined: 14 Jul 2013 12:33
Location: Netherlands

Re: WormAI

Post by Wormnest »

ALL AI'S HAVE ERROR BUT TERRON WORK'S GREAT.
Did you manually download the AI's instead of using the in game content download?

In that case you also need to manually download all required AI libraries including the dependencies of those libraries. Although, I'm not sure if that is still possible.

In the case of WormAI that means:
- Superlib version 40 (which needs several other libraries)
- AILib.List version 3
xarick
Transport Coordinator
Transport Coordinator
Posts: 336
Joined: 26 Feb 2015 00:52

Re: WormAI

Post by xarick »

Division by zero

return (100 * AIIndustry.GetLastMonthTransported(ind, cargo) / AIIndustry.GetLastMonthProduction(ind, cargo));

I presume the game advanced to a new month when the function was called and production last month was updated to 0.
Attachments
screenshot#5.png
(128.05 KiB) Not downloaded yet
Formerly known as Samu
Wormnest
Engineer
Engineer
Posts: 117
Joined: 14 Jul 2013 12:33
Location: Netherlands

Re: WormAI

Post by Wormnest »

Thanks, fixed it locally. I probably won't have time to release a new version anytime soon.
Wormnest
Engineer
Engineer
Posts: 117
Joined: 14 Jul 2013 12:33
Location: Netherlands

Re: WormAI

Post by Wormnest »

Issue above is now fixed in version 9.
peter1138
OpenTTD Developer
OpenTTD Developer
Posts: 1729
Joined: 30 Mar 2005 09:43

Re: WormAI

Post by peter1138 »

This AI assumes that MAIL exists as a cargo, and will crash if it does not exist.
He's like, some kind of OpenTTD developer.
Wormnest
Engineer
Engineer
Posts: 117
Joined: 14 Jul 2013 12:33
Location: Netherlands

Re: WormAI

Post by Wormnest »

Thanks, fixed in v10, available on Bananas.
peter1138
OpenTTD Developer
OpenTTD Developer
Posts: 1729
Joined: 30 Mar 2005 09:43

Re: WormAI

Post by peter1138 »

Wow, that was quick, thanks! :D
He's like, some kind of OpenTTD developer.
xarick
Transport Coordinator
Transport Coordinator
Posts: 336
Joined: 26 Feb 2015 00:52

Re: WormAI

Post by xarick »

Crash!
Captura de ecrã 2024-02-20 115510.png
Captura de ecrã 2024-02-20 115510.png (30.99 KiB) Viewed 243 times
Attachments
wormai crash.sav
(34.65 KiB) Downloaded 7 times
Formerly known as Samu
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 9 guests