PathZilla (v6) - A networking 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
User avatar
CommanderZ
Tycoon
Tycoon
Posts: 1872
Joined: 07 Apr 2008 18:29
Location: Czech Republic
Contact:

Re: PathZilla (v5) - A networking AI

Post by CommanderZ »

jui-feng wrote:Ah - Yes! That may very well be. However, the trees don't seems to help with the rating, as it's still bad (and no more tree space available ;)).
I wonder why Pathzillas rating is that awful? mh. And how did it burn almost 100k EUR for one city, marking only 20 or so tiles as "brown" (tree)? Last time I checked, trees were only EUR 50 or something. ;)

But yeah. Maybe it's not a bug after all. I'm not sure. ;-)
Maybe bribing? (can AIs bribe?)

User avatar
Zutty
Director
Director
Posts: 565
Joined: 22 Jan 2008 16:33

Re: PathZilla (v5) - A networking AI

Post by Zutty »

WOW! Thanks for all the replies guys :) I can hardly keep up.
dbkblk wrote:Oops...the RAWR monster crashed again ...
I was wondering if anyone would comment on the RAWR! :D This bug should be easy to fix.

When selecting an engine the AI discounts expensive ones that it cannot afford. The problem is that when the AI runs out of money it cannot afford any of them and simply doesn't make a choice! There should also be a null check to allow it to fail gracefully.

Thanks for the report. Expect a fix in v6.
jui-feng wrote:Hi again!

I "played" (watched?) another game. This time, I chose a hilly map and also there's more water than before.

First attempt: Pathzilla calculated a route between a small island and the main island over the span of the first year, before I cancelled it. Maybe it should break or pause the attempt after a certain reasonable time span.
Thanks again jui-feng. I think I know the kind of thing you are talking about. Eventually I will add a feature to detect bodies of water that cannot be bridged and forbid the pathfinder from trying to cross them. This will probably be in v7.
Second attempt: Everything seemed to work nicely, however I noticed a strange behavior: Pathzilla burned a lot of money for "Sonstiges" (engl. misc?), which is pretty much for landscaping only.
I eventually noticed that sometimes the "Sonstiges" budget jumps up by 16k or something like that in a few seconds. At the same time, Pathzilla outputs a "Building road stations in XXX town" message and there are "brown" tiles near the town (see screenshot). Sometimes this repeats a few times, and sometimes Pathzilla succeeds in building stations and everything is okay.

However, sometimes all that (bombing? land raising?) leads to bad authority ratings, so red errors appear.
X_stream wrote:I think I can help you out on that last error.. if you want to call it one.

PathZilla tends to build trees around towns to boost the ratings
But it seems you play with trees set to transparant, so you only see brown squares where it builds trees.
jui-feng wrote:Ah - Yes! That may very well be. However, the trees don't seems to help with the rating, as it's still bad (and no more tree space available ;)).
I wonder why Pathzillas rating is that awful? mh. And how did it burn almost 100k EUR for one city, marking only 20 or so tiles as "brown" (tree)? Last time I checked, trees were only EUR 50 or something. ;)

But yeah. Maybe it's not a bug after all. I'm not sure. ;-)
It builds as many trees as it can until it either increases the rating above a certain level, fills the entire area around the town with trees, or spends more than a limit of £8,000 (€16,000) in one go. €240,000 per year is a bit excessive though! I might try to tune this a bit.

Incidentally, is the setting to allow DTRSs on town roads turned on in your game?
CommanderZ wrote:
jui-feng wrote:Ah - Yes! That may very well be. However, the trees don't seems to help with the rating, as it's still bad (and no more tree space available ;)).
I wonder why Pathzillas rating is that awful? mh. And how did it burn almost 100k EUR for one city, marking only 20 or so tiles as "brown" (tree)? Last time I checked, trees were only EUR 50 or something. ;)

But yeah. Maybe it's not a bug after all. I'm not sure. ;-)
Maybe bribing? (can AIs bribe?)
Yes but this costs a fortune! PathZilla will not start bribing until it has more than £3,000,000 available.
PathZilla - A networking AI - Now with tram support.

jui-feng
Engineer
Engineer
Posts: 35
Joined: 01 Feb 2009 15:20
Location: Germany

Re: PathZilla (v5) - A networking AI

Post by jui-feng »

Well, currently admiralAI seems to outperform Pathzilla every time i try, but I still like Pathzilla more. ;)

DTRSs on roads are enabled (if that means "bus or post stops" ;) ), and Pathzilla happily builds them all over the place. But somehow it spends really large amounts of money on trees (I disabled transparency to check that). The 16.000 EUR/go-limit seems to be pretty "useless", as there is only a few seconds of waiting time between two mainloop (?) iterations, so 16k pretty soon adds up to a few thousands, if there's enough space available. Also, it started growing trees when the rating was actually "good", so there should have been no problem.
The green belt still is a great feature. :-) Maybe it should only do it if there are real problems (local authority doesn't allow building a station) or if the estimated cost of building the trees still makes building the stations worthwile.. I don't know.

Maybe some patch setting I use causes cities to be extremely strict about their ratings?

AdmiralAI doesn't grow trees and can still build stations without problems. And on top of that Admiral uses all the 1.000.000 EUR it can get as a credit. Pathzilla only goes in dept to a total of 500.000, resulting in a slower "start up speed".

I also noticed that AdmiralAI often "steals" (or rather shares) routes built by Pathzilla (very shortly after Pathzilla built them). That's also a reason why it performs better. Pathzilla doesn't steal Admiral's routes, but that's fine, since they probably don't fit into the Pathzilla network.

Thanks for the hard work. Just compare it to the original TTD AI.. :-) I wonder if i'd be able to win a game vs. Pathzilla... :shock:

Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: PathZilla (v5) - A networking AI

Post by Yexo »

jui-feng wrote:AdmiralAI doesn't grow trees
That's not true. It may not be as visible as with PathZilla, that's possible, but AdmiralAI does build trees if it can't build an airport or rail station.
I also noticed that AdmiralAI often "steals" (or rather shares) routes built by Pathzilla (very shortly after Pathzilla built them).
It'll notice there is a route, but the "% transported last month" is still low (or even 0), because PathZilla just started transporting the goods. There is no way to determine whether the route has been there for several years and other companies are just providing bad service or whether it's a new route. The only way I can think of would be to save all found routes and use them if a year later there is still no good transportation but that would hurt performance (a lot).

/me starts a game with PathZilla to see how the latest version works ;)

Edit: this must be a small bug, I forgot to save the game. Please tell me if a savegame will help you:
pathzilla-5.png
pathzilla-5.png (66.27 KiB) Viewed 3653 times

jui-feng
Engineer
Engineer
Posts: 35
Joined: 01 Feb 2009 15:20
Location: Germany

Re: PathZilla (v5) - A networking AI

Post by jui-feng »

Hey Yexo!

I didn't mean to say that your AI *can't* build trees at all, but it didn't do this in *my* Pathzilla/AdmiralAI game. So what I actually wanted to say is: Pathzilla spent more than 300k EUR on trees in 3 years, while AdmiralAI seemingly built no trees at all, thus having more money left for stations/vehicles/.. Which is basically a good thing, unless you consider trees a very important feature of OpenTTDs landscape. :)

And "stealing routes" is - usually - a clever thing I guess, so why fix it? ;) Okay, maybe it's kind of bad if human players suffer from it..

Also, I'm really impressed by how fast your AdmiralAI raises it's network. I guess all AIs have their strengths, and I like the networking character of Pathzilla most, but that's just me. :-) I'm always looking forward to new versions of any AI out there. It's very interesting to see them work.

User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4554
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: PathZilla (v5) - A networking AI

Post by Zuu »

Yexo wrote:
jui-feng wrote:AdmiralAI doesn't grow trees
There is no way to determine whether the route has been there for several years and other companies are just providing bad service or whether it's a new route. The only way I can think of would be to save all found routes and use them if a year later there is still no good transportation but that would hurt performance (a lot).
This might surely hold for current API. Since the philosophy is that the AI should only be able to do things that the player can do I'd like to point out that using the query tool a player can determine when a station was built. Another way would be to look at the vehicles that service the station and see which age they have.


I just checked the API and it seams like it doesn't explicitly say that you can't get the station ID of a station that belong to another company. And with the station ID of another company then get a AIVehicleList_Station list. And then check the age of the oldest vehicle. But I guess you know better if that is possible/allowed or not.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: PathZilla (v5) - A networking AI

Post by Yexo »

Zuu wrote:I just checked the API and it seams like it doesn't explicitly say that you can't get the station ID of a station that belong to another company. And with the station ID of another company then get a AIVehicleList_Station list. And then check the age of the oldest vehicle. But I guess you know better if that is possible/allowed or not.
You only get some information about what your opponents are doing. Whether that is good thing or not, I don't want to discuss now (but feel free to open a new topic).

AIStation::GetStationID(tile) will return a StationID for station belonging to your opponents, but AIStation::IsValidStation will return false for that StationID (so every other AIStation fails on that id). About the station age, is that information usefull in any way? (Assuming you can only get the age of your own stations).

User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4554
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: PathZilla (v5) - A networking AI

Post by Zuu »

Yexo wrote:
Zuu wrote:I just checked the API and it seams like it doesn't explicitly say that you can't get the station ID of a station that belong to another company. And with the station ID of another company then get a AIVehicleList_Station list. And then check the age of the oldest vehicle. But I guess you know better if that is possible/allowed or not.
You only get some information about what your opponents are doing. Whether that is good thing or not, I don't want to discuss now (but feel free to open a new topic).

AIStation::GetStationID(tile) will return a StationID for station belonging to your opponents, but AIStation::IsValidStation will return false for that StationID (so every other AIStation fails on that id). About the station age, is that information usefull in any way? (Assuming you can only get the age of your own stations).
It was most a suggestion on how you could solve your issue with knowing how old a connection is. Not something I will look into myself anytime soon.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

User avatar
Zutty
Director
Director
Posts: 565
Joined: 22 Jan 2008 16:33

Re: PathZilla (v5) - A networking AI

Post by Zutty »

Yexo wrote:Edit: this must be a small bug, I forgot to save the game. Please tell me if a savegame will help you:
pathzilla-5.png
Thanks for the bug report Yexo. I thought I had fixed this!

I wont trouble you for a save but can you remember anything unusual about the construction for the service? Perhaps there were no stations built at the other end? Had the AI run out of money?

Thanks.
PathZilla - A networking AI - Now with tram support.

wozzar
Transport Coordinator
Transport Coordinator
Posts: 328
Joined: 27 Dec 2002 09:25

Re: PathZilla (v5) - A networking AI

Post by wozzar »

I am using version 15339 nightly. And i cant get PathZilla to work. I have four unnamed players not doing anything.

Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: PathZilla (v5) - A networking AI

Post by Yexo »

wozzar wrote:I am using version 15339 nightly. And i cant get PathZilla to work. I have four unnamed players not doing anything.
Then you should make a screenshot of the ai debug panel (found under the red question mark, the rightmost button in the toolbar) and post it here. The errors are listed there.

wozzar
Transport Coordinator
Transport Coordinator
Posts: 328
Joined: 27 Dec 2002 09:25

Re: PathZilla (v5) - A networking AI

Post by wozzar »

Yexo wrote:
wozzar wrote:I am using version 15339 nightly. And i cant get PathZilla to work. I have four unnamed players not doing anything.
Then you should make a screenshot of the ai debug panel (found under the red question mark, the rightmost button in the toolbar) and post it here. The errors are listed there.
As requested. Here is the debug panel.
Attachments
Unnamed, 23rd Jan 2003.png
Unnamed, 23rd Jan 2003.png (76.57 KiB) Viewed 3334 times

User avatar
Zutty
Director
Director
Posts: 565
Joined: 22 Jan 2008 16:33

Re: PathZilla (v5) - A networking AI

Post by Zutty »

wozzar wrote:
Yexo wrote:
wozzar wrote:I am using version 15339 nightly. And i cant get PathZilla to work. I have four unnamed players not doing anything.
Then you should make a screenshot of the ai debug panel (found under the red question mark, the rightmost button in the toolbar) and post it here. The errors are listed there.
As requested. Here is the debug panel.
You're missing the aystar library.

Did you download PathZilla via the content service? If not, try deleting the pathzilla.tar file you have now and then download it in game using the "Check online content" button. This will download the aystar library for you automatically.
PathZilla - A networking AI - Now with tram support.

User avatar
Zhall
Tycoon
Tycoon
Posts: 1244
Joined: 17 Jul 2007 01:36
Skype: moonray_zdo
Location: Teh matrix, duh.
Contact:

Re: PathZilla (v5) - A networking AI

Post by Zhall »

Rawr Goes pathzilla! Truely amazing AI. The flashing cat strikes again, or the cat in hyperspace? Really i cant tell.
Last edited by Zhall on 05 Feb 2009 00:32, edited 1 time in total.

wozzar
Transport Coordinator
Transport Coordinator
Posts: 328
Joined: 27 Dec 2002 09:25

Re: PathZilla (v5) - A networking AI

Post by wozzar »

Zutty. Thanks i have resolved that issue. How ever i have another problem. All the AI are building bus routes but the road is being blocked.
Attachments
Fletfinghill City Transport, 11th Jan 2003.png
Fletfinghill City Transport, 11th Jan 2003.png (88.5 KiB) Viewed 3324 times

User avatar
Zutty
Director
Director
Posts: 565
Joined: 22 Jan 2008 16:33

Re: PathZilla (v5) - A networking AI

Post by Zutty »

wozzar wrote:Zutty. Thanks i have resolved that issue. How ever i have another problem. All the AI are building bus routes but the road is being blocked.
It looks like the area is busy. Judging by the debug output it has tried to build various roads in the same town and failed a few times.

This is probably due to other AIs competing for the limited space in that one town.

When I designed PathZilla I never expected people to want to run 8 AIs at the same time!! I'm going to have to change a few things to make it cope with situations like this better.

I have a few tweaks in mind for v6 that should help with this problem and also make it more efficient and robust.
Sapphire united wrote:Rawr Goes pathzilla! Truely amazing AI.
Thanks :) I'm glad people like it.
The flashing cat strikes again, or the cat in hyperspace? Really i cant tell.
Eh? :wink:
PathZilla - A networking AI - Now with tram support.

wozzar
Transport Coordinator
Transport Coordinator
Posts: 328
Joined: 27 Dec 2002 09:25

Re: PathZilla (v5) - A networking AI

Post by wozzar »

I ran it on 2 ai and it still couldn't complete road or it couldn't find path. Does it build anything else besides buses.

jui-feng
Engineer
Engineer
Posts: 35
Joined: 01 Feb 2009 15:20
Location: Germany

Re: PathZilla (v5) - A networking AI

Post by jui-feng »

Currently, it only transports passengers and mail (by road, no airplanes or trains involved).

My observation is that Pathzilla has two problems when starting in the year 1980 with "rather big" towns.
  • It tries to build a lot of stations (maybe up to 10) in every town it connects to the network (since these towns are big). With each station, the authority rating goes down a bit, soon forcing the AI to build trees. LOTS of trees. Maybe it would be better to just build a few stations in the beginning, then add more as the rating goes up because of a good transport service. But that's probably hard to implement.. I don't know.
  • It fails to build enough vehicles. At least that's what I think. Passengers soon start stacking up at most stations as the town grows, but no new vehicles are built. In fact, I've never seen Pathzilla add new vehicles after establishing a fleet. I changed the formula for updating a fleet, so now the number of waiting passengers has a stronger impact on new vehicles, but still it's not good, probably worse than the original formula.. The problem is that it's only possible to add new vehicles to a "service", and then all the vehicles are somehow randomly distributed across the stations. I've seen a major station in a city without any busses that go there. In order to be efficient, the new vehicles should connect two stations which have a lot of cargo waiting or bad station ratings (or both). I know there have been some changes to the "updating fleet" code in SVN (CVS? BZR? HG? well, source control..). I haven't tried that, so maybe it's better in v6. :)
You can't imagine how much fun it is for me watching Pathzilla for hours. :D

edit: whoops, list screwed up a bit.

User avatar
Zutty
Director
Director
Posts: 565
Joined: 22 Jan 2008 16:33

Re: PathZilla (v5) - A networking AI

Post by Zutty »

Thanks for the feedback jui-feng. (and sorry for my late reply).

Fleet sizes are a bit of an issue for me. I have done some tweaking so that v6 will have larger fleet sizes, and I have also added a setting to allow user control. The trouble is that the AI still builds ridiculous fleets. the code to calculate this is a follows...

The inital estimate is...

Code: Select all

fleetSize = (PathZilla.GetSetting("traffic") * minAcceptance / (capacity * 2)) * ((distance * 3) / speed);

local year = AIDate.GetYear(AIDate.GetCurrentDate());
if(year < 1950) {
	year = max(year, 1905);
	fleetSize = (fleetSize * (year - 1900)) / 50;
}
Once the service has beenc reated it is periodically modified by...

Code: Select all

local year = AIDate.GetYear(AIDate.GetCurrentDate());
year = min(max(year, 1915), 1950);
local multiplier = (65 - (year - 1900)) / 2;
multiplier /= PathZilla.GetSetting("traffic");
fleetSize = (waitingCargo / (capacity * multiplier)) * ((distance * 3) / speed)
Where...
minAcceptance = Total amount of cargo acceptance for all stations in the smallest town in a service
waitingCargo = Total cargo waiting at all stations in all towns of a service
capacity = Cargo capacity of vehicle
distance = Distance between towns
speed = Speed of vehicle

The current year is a factor to make early vehicles profitable (e.g. eGRVTS's horse drawn carriages). The "traffic" setting is a value between 1 and 4. You can see that a higher value results in a larger fleet size. This isn;t set in stone. I'll happily change this if someone has a better suggestion.

For large cities that are close together it builds a minimal fleet (i.e. one per station), and for small villages that are very far away it WANTS to build thousands. I had to put a limit in place. I think I can fix this by reducing the distance term in the above calculations, but I still think the whole thing is a bit flawed.

Does anyone have any suggestions? :)

By the way, although I am very busy at the moment, v6 is still progressing. PathZilla now has crude industry support...
pz-indsupport.png
pz-indsupport.png (55.39 KiB) Viewed 2995 times
For some wierd reason it keeps building these loops around industries. I never told it to do that! Do you think this is ugly?

Plus I'm still deciding how to reconcile my networking approach with profitable routes that don't jam up very quickly. If I link industries directly then lots of extra roads are added, and support to town grids (2x2/3x3) is ruined, but if I link industries via towns then traffic gets ridiculous. Again, suggestions are welcome. :)
PathZilla - A networking AI - Now with tram support.

jui-feng
Engineer
Engineer
Posts: 35
Joined: 01 Feb 2009 15:20
Location: Germany

Re: PathZilla (v5) - A networking AI

Post by jui-feng »

That screenshot is great. :) I'm really looking forward to a new release! I don't think the loops are a problem. I might get the source from google code in the next days and try it out. :)

I changed the "update fleet" code so it loops through all stations in both towns of a service and adds new vehicles to any stations where the cargo rating is below 55%. If one town has a station with 53%, while the worst rating in the other town is 60%, it still connects those stations even though one station has a good rating. Of course, in order for this to function correctly, I had to disable your "load balancing" feature where all the vehicles of a service are "randomly" (not quite random, but you get what I mean?) distributed between all the stations whenever there is a new station built.

I soon noticed that this approach is not very useful, as it leads to very big traffic jams and useless buying of new vehicles (because of the traffic jam, the station ratings can not possibly go above 55%). So I introduced a limit to the amount of vehicles that are allowed to be connected to a station, but that's not very good either, as there's still a lot of traffic jams and I don't want to lower the limit. A traffic jam detection is what my "mod" needs in order to be efficient. I'm not sure how to do that (measure traveling time between the stations?). But still, I'm not sure if it could be any better than your current approach, just wanted to see how squirrel and your AI works. :-)

Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 7 guests