WmDOT v14 [2016-08-29]

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

xarick
Transport Coordinator
Transport Coordinator
Posts: 336
Joined: 26 Feb 2015 00:52

Re: WmDOT v13 [2014-03-10]

Post by xarick »

WmDOT needs to use No Load or Unload and leave empty, so it doesn't load Oil waiting. There are Oil Wells behind this refinery causing it to fail to unload at that docks.
Attachments
screenshot#28.png
(125.07 KiB) Not downloaded yet
Formerly known as Samu
User avatar
MinchinWeb
Traffic Manager
Traffic Manager
Posts: 225
Joined: 01 Feb 2011 12:41
Contact:

Re: WmDOT v13 [2014-03-10]

Post by MinchinWeb »

@xarick: what is the industry set you are using? Does it have a limit on how much oil the refinery will process?
Alberta Town Names - 1500+ real names from 'Acme' to 'Zama City'
MinchinWeb's Random Town Name Generator - providing 2 million plus names...
WmDOT v13 - An AI that doubles as your highway department
xarick
Transport Coordinator
Transport Coordinator
Posts: 336
Joined: 26 Feb 2015 00:52

Re: WmDOT v13 [2014-03-10]

Post by xarick »

I'm not using any newgrf.

I created a scenario to recreate the issue and started WmDOT on it. See attached savegame.
Attachments
Unnamed, 1964-12-11.sav
(12.01 KiB) Downloaded 177 times
Formerly known as Samu
xarick
Transport Coordinator
Transport Coordinator
Posts: 336
Joined: 26 Feb 2015 00:52

Re: WmDOT v13 [2014-03-10]

Post by xarick »

Image

nardham oilfield and flartwood docks are so close, but wmdot decides to use 3 ship depots located way too far away to duplicate ships.
Attachments
WmDOT, 1st Sep 2041.sav
(1.13 MiB) Downloaded 181 times
Formerly known as Samu
Trainmaster_Lucario
Engineer
Engineer
Posts: 1
Joined: 10 Aug 2016 19:03

Re: WmDOT v13 [2014-03-10]

Post by Trainmaster_Lucario »

I keep getting the Error Message saying some scripts don't exist. I am like WTF :x
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: WmDOT v13 [2014-03-10]

Post by Alberth »

If you also post the actual error message, we might be able to help you.

(Posting "some scripts are missing" offers very few clues as to what it actually wants, there are several hundred to thousand of scripts.)
Being a retired OpenTTD developer does not mean I know what I am doing.
xarick
Transport Coordinator
Transport Coordinator
Posts: 336
Joined: 26 Feb 2015 00:52

Re: WmDOT v13 [2014-03-10]

Post by xarick »

Hi, I just tried this fix for the issue regarding loading Oil at the destination Dock when there's Oil Wells near the catchment area.

Change line 474 of OpHibernia.nut from

Code: Select all

AIOrder.AppendOrder(MyVehicle, DockLocation, AIOrder.OF_NONE);
to

Code: Select all

AIOrder.AppendOrder(MyVehicle, DockLocation, AIOrder.OF_NO_LOAD);
Unnamed, 1979-03-04.png
Unnamed, 1979-03-04.png (185.06 KiB) Viewed 5522 times
EDIT: on second though, unload and leave empty is better, due to the way WmDOT keeps adding ships based on waiting cargo. I'm unsure if WmDOT manages oil refineries closures.

Code: Select all

AIOrder.AppendOrder(MyVehicle, DockLocation, AIOrder.OF_UNLOAD | AIOrder.OF_NO_LOAD);
Unnamed, 1962-01-19.png
Unnamed, 1962-01-19.png (107.63 KiB) Viewed 5517 times
Formerly known as Samu
xarick
Transport Coordinator
Transport Coordinator
Posts: 336
Joined: 26 Feb 2015 00:52

Re: WmDOT v13 [2014-03-10]

Post by xarick »

Hey, regarding the other issue about ship depot choice for cloning ships. I got it all wrong. Here's a better observation:

WmDOT wants to duplicate ships based on waiting cargo on two routes, example, log route 47 and 48 (group route 48 and 49), with 1300 oil waiting at the same oil rig "A" for both routes.

It proceeds to duplicate 2 ships using the depot of log route 47 and 48 (group route 48 and 49) which share the same depot. However, the orders they get are wrong. They get the orders of log route 55 (group route 56) which is more than 1000 tiles away from the ship depot choice. Also, log route 55 (group route 56) oil rig "B", is already well serviced with ships saturating with no oil waiting. All these duplicated 200+ ships that cross the world aren't even going to profit once they reach their destination.

I guess there is some industry/order pair mismatching that happens at some point past 2010. I've never seen WmDOT with this issue before this year.

One other strange observation, is that WmDOT does very well from 1950 to 2010. At this point, it sells most of his ships, like 90% of all ships are sold, he only keeps a few. I am unsure if it's related, but by year 2010, the old oil cargo ship model is no longer available, but doesn't seem to make much sense, as it expires around 1990, not 2010.


EDIT: OOPS, nevermind, the log range for routes is from 0 to 55, the group names for routes are from 1 to 56, my bad. The log was misleading me. Fixed explanation to mention both.
EDIT2: Oh, you may notice that the ships have unload and leave empty in the orders, I was using a modified version of wmdot based on v13, I think it should be compatible with the original v13.
Attachments
Unnamed, 2044-08-29.sav
(728.73 KiB) Downloaded 172 times
Formerly known as Samu
User avatar
MinchinWeb
Traffic Manager
Traffic Manager
Posts: 225
Joined: 01 Feb 2011 12:41
Contact:

Re: WmDOT v14 [2016-08-29]

Post by MinchinWeb »

@xarick: I've released v14 of WmDOT to fix the unloading bug you uncovered. I personally don't really like to force something to unload, but I don't have a good way otherwise to check for issues like this.

As for the extra ships being creating, I agree with you that the wrong depot is being used. I'm still not sure why. WmDOT assigns the depot when the route is first created, but also recreates them on reloading the game from a save.

WmDOT doesn't do anything if an industry closes. If all the applicable ships were sent to a depot, they should be sold automatically. The stub code, however, can be found in Event.Handler.nut, lines 149-151:

Code: Select all

			case AIEvent.ET_INDUSTRY_CLOSE:
				Log.Note("Nice event and all, but I have no idea what to do about it...", 4);
				break;
The mass ship selling seems unusual, and I'm not sure what would cause it. My first guess would (again) be some issue relating to when the AI is reloaded after a savegame is loaded. WmDOT should automatically sell ships if there are too many on a given route as well.

---

The ship portion of the AI has never been as polished as the road portion. The ships were created mostly to keep WmDOT from going broke from road building, and to that end, I feel like they work reasonably well. That said, I will continue to happy accept suggestions and improvements.
Alberta Town Names - 1500+ real names from 'Acme' to 'Zama City'
MinchinWeb's Random Town Name Generator - providing 2 million plus names...
WmDOT v13 - An AI that doubles as your highway department
xarick
Transport Coordinator
Transport Coordinator
Posts: 336
Joined: 26 Feb 2015 00:52

Re: WmDOT v14 [2016-08-29]

Post by xarick »

Hi, thx for fixing it. I will try the new version as soon as I can.

I see that my explanation is still confusing. I will try to explain a bit better. Also, I forgot to mention, my testing was running for 100 years straight, from 1950 to 2051 without loading any savegame. I had the server configured to do monthly autosaves, and keep all autosaves, but the testing sessions were uninterrupted.

The issues start after a 60+ years game session, by the year 2010. From 1950-1960 WmDOT doesn't build any ship, but that's normal. Oil Rigs only start showing up from 1960 onwards.

From 1960-2010, all his ship management, and build construction seem correct. I haven't noticed anything abnormal during this period, profit graphs are always rising. One particular thing I notice is that when the new oil ship model becomes available (350 m3), and WmDOT finds out that some routes need more ships, it still duplicates the old ship model (220 m3) on already existant routes. Only the new routes get to use the new model. I see that this new model becomes available around 1969. Both old and new models co-exist from 1969 to 1990. Past 1990, I am not really sure what WmDOT does about those routes created before 1969 in regards to the need of adding more ships to a route.

Regardless, there is nothing strange happening during this period from 1990 to 2010, or at least, I have not noticed anything gone wrong. Sometimes I see some routes that have the exact same oil rig, same ship depot assignment and same orders. I'm unsure if this is how WmDOT deals with the two different ship models. Profits are still going strong, with no sign of declining, up till the year ~2010.

Once in ~2010, WmDOT goes crazy. I remember in one of the sessions, WmDOT had about 120 ships, but sells almost everything it had, and reached a minimum of 8 ships. I tried to look at the model of those 8 ships, and there is something in common, 7 out of 8 ships were the 350 m3 model, only the other lonely ship was the 220 m3 model. What could this mean? I'm not really sure. If my memory serves me right, these 8 ships were still profiting, but going from 120 to 8 really had a serious impact on the profit graph, it took a really sharp decline in the span of a few quarters.

From 2010 onwards, WmDOT does appear to reawake and start rebuilding more ships, but the profits grow at a slower pace, the profits start rising up again, everything seems to be ok, but then, at some point past 2010, sometimes 5 years later, sometimes even later, it will start having the issues about the duplication of ships.

Taking the example from my previous post, Here's the pairings that I could observe:
- log of route 47: has the oil rig "A", the orders "oil rig A to A refinery", ship names have "route 48" mentioned, vehicle group name is "group 48". Ship depot is nearby, close to the oil rig A.
- log of route 48: has the oil rig "A", the orders "oil rig A to A refinery", ship names have "route 49" mentioned, vehilce group name is "group 49". Ship depot is nearby, close to the oil rig A. Coincidence or not, the oil rig, the orders and the ship depot are the same as of log or route 47.
- log of route 55: has the oil rig "B", the orders "oil rig B to B refinery", ship names have "route 56" mentioned, vehicle group name is "group 56".

Reading the log that WmDOT prints, it iterates over all the oil rigs from all routes to see if it would need a new ship:
- at log of route 47, it mentions the oil rig got 1300 oil waiting and adds one more ship. It correctly choses the nearest depot, but then when adding the orders, they are from log of route 55. The ship gets named with "route 56" mentioned in it, and is added to the "group 56"
- at log of route 48, it mentions the oil rig got 1300 oil waiting and adds one more ship. It correctly choses the nearest depot, but then when adding the orders, they are from log of route 55. The ship gets named with "route 56" mentioned in it, and is added to the "group 56".
- at log of route 55, it mentions the oil rig got 0 oil waiting and doesn't do anything more. This is also coincides with the last route from the logged iteration list, and also the last vehicle group from the vehicle group list.

When I first reported about the issue, it gave me the impression that WmDOT was picking the wrong ship depot, but giving the correct orders, but it's the other way around. It is picking the correct ship depot, but giving the wrong orders.
Formerly known as Samu
xarick
Transport Coordinator
Transport Coordinator
Posts: 336
Joined: 26 Feb 2015 00:52

Re: WmDOT v14 [2016-08-29]

Post by xarick »

Image

One image is worth a thousand words.

There are several problems after all, they were only being masked. wmdot is trying to clone ships based on the old model. There is no error message, but it's repeatedly trying to do that everytime re-checks.

The mass selling of ships is originated by an oil rig closure. Some ships are told to go to depot, twice in a row, which means they cancel that order.

Some parts of the script seems to be running twice. One example was that of ships going to depot twice, another one I noticed was about the save message "save not implemented" appearing twice.
Formerly known as Samu
User avatar
MinchinWeb
Traffic Manager
Traffic Manager
Posts: 225
Joined: 01 Feb 2011 12:41
Contact:

Re: WmDOT v14 [2016-08-29]

Post by MinchinWeb »

@xarick: Thank you for the detailed report. This will be very helpful in figuring out what's going on. My other commitments have kept my away from WmDOT (and OpenTTD) longer than I thought, but I can write some explanation of what WmDOT is doing here in the meantime.

Post-1990, it seems that on routes where the old, small ship is in use, WmDOT tries to duplicate the small ship, but this fails (in your image, see "Funds Request -1L" for routes 4, 5, 6, and 9; WmDOT is asking for an additional loan to build the ship). In theory, eventually the oil rigs serviced by these routes will become under-serviced enough for WmDOT to re-create the route, but with a different route number and the new ship. (This would be the cause of the multiple route numbers for the same combinations of oil rig-refinery-ship depot you're seeing). I suppose the "proper" solution would be to have a check when attempting to buy an additional ship to see if that model is still available, and if it isn't, to do something about it.

As for selling ships, WmDOT has a check that if a bunch of ships are setting empty at the loading dock, they should be sold off. (These are the log lines "Vehicle #XXX has been sent to the depot to be sold" are about. I'm not sure why #177 shows up twice....).

As for the 'save not implemented'; that's actually produced by the OpenTTD host directly rather than the AI. And I never knew why it was shown twice.

---

So based on what you've told me here, it seems that the next two features to be added to WmDOT should answers to the questions:

- what should WmDOT do if it wants to add a ship to a route and the current model is not available, or there's a new model available (probably upgrade? upgrade all the ships on the route?)
- what should WmDOT do is a source industry closes? (empty the ships and sell them all?)
- and, for bonus points, what should WmDOT do if the destination industry closes? (change the route to a new destination? close down the current route and make a new one?)
Alberta Town Names - 1500+ real names from 'Acme' to 'Zama City'
MinchinWeb's Random Town Name Generator - providing 2 million plus names...
WmDOT v13 - An AI that doubles as your highway department
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 6 guests