TownCars 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

User avatar
Gremnon
Tycoon
Tycoon
Posts: 1517
Joined: 16 Sep 2005 12:23
Skype: the_gremnon
Location: /home
Contact:

Re: TownCars AI

Post by Gremnon »

I don't think so, as I've also used the 0.9.1 version of Bigos' Server patch, which has both CargoDist and Infrastructure Sharing, and it works perfectly in that.

I guess I'll have to check it's not anything else I might have inadvertantly affected, but I'm fairly sure nothing directly affects depots or the AI
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: TownCars AI

Post by Zuu »

If I'm not mistaken TownCars will never destroy a house to build a depot. It will look for places adjacent to existing road where it can build a depot and connect it to the road.

If you observe a city that you see in the log that it tries and you observe a spot that you think it should have been able to use, then you can always submit a screenshot over the town.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
Gremnon
Tycoon
Tycoon
Posts: 1517
Joined: 16 Sep 2005 12:23
Skype: the_gremnon
Location: /home
Contact:

Re: TownCars AI

Post by Gremnon »

It doesn't appear to try anything. I could turn debug signs on, that's the only thing I haven't done yet, but so far, all it does is tell me it tried to build, then couldn't build - yet I see plenty of places where there are places to build, without needing to do anything more than plonk it down.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: TownCars AI

Post by Zuu »

Okay, I tried TownCars 4 on moutanious, very rough terrain with high sea level. It didn't seam to have any problems with finding a spot to place depots. I have tried both currently last nightly and 0.7.3.

Without having a screenshot of a 'failed' town or a scenario/save game that reproduce it, I can not help you since it works fine here.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
Gremnon
Tycoon
Tycoon
Posts: 1517
Joined: 16 Sep 2005 12:23
Skype: the_gremnon
Location: /home
Contact:

Re: TownCars AI

Post by Gremnon »

I think I might have found it, I'm not sure.
I've got all the Japanset GRF's loaded - that may or may not make a difference. The Generic cars GRF is loaded after them.
I've been playing on a 64x256 (or, of course, 256x64) map.
On a map that thin in one direction, it seems like somethings giving it trouble. If I move up to 128 instead of 64, they work fine again.

So I think it might be small maps in either directions causing trouble.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: TownCars AI

Post by Zuu »

It is probably related to towns close to the border. Or more specificly tile coordinates that warp around, causing the problem. Thanks for the help narrowing it down.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
Gremnon
Tycoon
Tycoon
Posts: 1517
Joined: 16 Sep 2005 12:23
Skype: the_gremnon
Location: /home
Contact:

Re: TownCars AI

Post by Gremnon »

Posting here because this is where StreetTraffic hides as well, and I have a possible bug report:
Debug output it:

dbg: [ai] [2] Your script made an error: the index 'rawin' does not exist
dbg: [ai] [2]
dbg: [ai] [2] *FUNCTION [Load()] ~/.openttd/content_download/ai/StreetTraffic1.1.0.tar/streettraffic1.1.0/main.nut line [450]
dbg: [ai] [2]
dbg: [ai] [2] [Name] "Town8"
dbg: [ai] [2] [@ITERATOR@] 8
dbg: [ai] [2] [dummy] 0
dbg: [ai] [2] [TownId] 8
dbg: [ai] [2] [TownList] INSTANCE
dbg: [ai] [2] [data] CLOSURE
dbg: [ai] [2] [S] [version] INSTANCE
dbg: [ai] [2] [S] [this] INSTANCE
dbg: [ai] The AI died unexpectedly.

Happened immediately after loading a game. To my knowledge, it wasn't trying to do anything when I saved the game either.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: TownCars AI

Post by Zuu »

That looks like StreetTraffic1 which is known to be broken. The original author of it has not just been around to disable it at bananas.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
Gremnon
Tycoon
Tycoon
Posts: 1517
Joined: 16 Sep 2005 12:23
Skype: the_gremnon
Location: /home
Contact:

Re: TownCars AI

Post by Gremnon »

Known to be broken?
Well, was there ever a second version?

And as to the broken... it actually plays quite well. It seems to be able to start up better than TownCars, and, IMO, it does a lot better than it too - I think the bit I like about it most is that it doesn't just go to sleep, it checks again and builds a few more cars.

If nothing else, it's more of a challenge to do road vehicle routes with the traffic it generates.

TownCars isn't bad, I'm not saying it is - but I think there's a few things it could learn from StreetTraffic.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: TownCars AI

Post by Zuu »

StreetTraffic1 is a branch of TownCars with some improvements that I stated that I will not spend my time on but welcomed anyone to work on the requested improvements. [Edit: See this post http://www.tt-forums.net/viewtopic.php?p=774828#p774828 ]

And for the brokenness, it has indeed more features but since it is branched from TownCars 3 it does not contain the bug fixes in TownCars 4. There was a time when both of them didn't work because of changes in OpenTTD. (I don't remeber 100% if it was only trunk or also stable) TownCars 4 was a fix to address these problems. I haven't tested StreetTraffic 2, but I'm sure it works on the current releases of OpenTTD. StreetTraffic 2 you can find a few posts earlier in this thread.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
Gremnon
Tycoon
Tycoon
Posts: 1517
Joined: 16 Sep 2005 12:23
Skype: the_gremnon
Location: /home
Contact:

Re: TownCars AI

Post by Gremnon »

Well, I'll have a try with version 2 then. Maybe this will spur me into branching out into AIs too, and I'll see if I can't bring it up to date a bit.
Spedichef
Engineer
Engineer
Posts: 12
Joined: 21 Mar 2005 11:36

Re: TownCars AI

Post by Spedichef »

Short update on StreetTraffic V2 Info: I compiled today the r18393 nightly and the "rawin" issue has been fixed. The AI now survives saving and loading.
tawkeer
Engineer
Engineer
Posts: 12
Joined: 09 Feb 2007 06:37
Contact:

Re: TownCars AI

Post by tawkeer »

streettraffic means traffic signals for road vehicles?
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: TownCars AI

Post by Zuu »

tawkeer wrote:streettraffic means traffic signals for road vehicles?
No, please re-read this topic. Then you get both the history of the TownCars AI and the StreetTraffic AI and what it is all about. It is just two and a half pages, so it shouldn't take you that long.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
tawkeer
Engineer
Engineer
Posts: 12
Joined: 09 Feb 2007 06:37
Contact:

Re: TownCars AI

Post by tawkeer »

ok, i got it.....depot and wandering cars.... :shock:
User avatar
Szappy
Chief Executive
Chief Executive
Posts: 689
Joined: 29 Mar 2004 14:35
Location: Budapest, Hungary
Contact:

Re: TownCars AI

Post by Szappy »

I do not know if this AI is being developed any further, but it would be nice if it got a few improvements.
I'm using the v2 atm. but had to download it from this topic.
Would be nice if it was available to download from inside the game. How is that possible?

I tried understanding the code and... well... failed miserably.
Could someone guide me in modifying it in the following way:
- I noticed that if the AI is in a car building loop in a single town, it never checks its loan amount, and sometimes gets bankrupt although it only has a loan of 20-30000 out of 1M. What should I modify for it to check the loan regularly, and borrow some money if it's close to 0Ł?
- I also noticed that it builds all the depots it will need first then start building cars. This could be to an advantage. Currently it can happen that the max amount of cars is reached in the single most populated town, and nothing will be built elsewhere. I'd like to modify the car building loop that the AI buys one car in every depot not only in the most populated town, then start the loop again. That way the towns are filled up gradually not starting from the most populated one.
- Another nice feature could be that a second (third...) replica of the AI does not choose the same towns already taken by previous instance(s). It should probably know which ones were taken already, because: 1) it knows how many instances of the same AI exist (naming), and 2) it knows how many towns the previous ones took, because of settings. So if the AI is allowed to build in 20 towns, the second replica should skip the 20 most populated towns. Naturally it needs some check not to overrun the towns list.

Are these changes possible?
Can someone knowledgeable guide me to do these?

Thanks in advance:
Szappy
Image please use email instead of PM
Spedichef
Engineer
Engineer
Posts: 12
Joined: 21 Mar 2005 11:36

Re: TownCars AI

Post by Spedichef »

Hi Szappy

Some of your points have been realized in the Streettraffic-Spinoff: Link

It checks the loan and tries to survive as long as possible, by reducing the loan to the minimum. Unfortunately there is no option to avoid the AI bankruptcy (at least I do not know one).

In the AI config GUI (reachable via main menu), you can also define, where and how many cars will be build.

Rgds
Tim
User avatar
Szappy
Chief Executive
Chief Executive
Posts: 689
Joined: 29 Mar 2004 14:35
Location: Budapest, Hungary
Contact:

Re: TownCars AI

Post by Szappy »

Hello Spedchief,

Actually that's the one I'm using (and trying to understand/modify) right now :D
-edit- sorry I was not really clear about the v2, I'm talking about Street Traffic v2, not Towncars v2

I also have an idea to extend the lifetime (maybe even to make it profitable?):
build 'random' bus stops in the major towns (maybe 2 or 3) and the cars stopping there randomly will make some (very small) profit.
Since they cost nothing, this income could balance out the loan interest.

Although realizing this is definitely out of my league.

What do you think about my other points?
Possible?
Image please use email instead of PM
Spedichef
Engineer
Engineer
Posts: 12
Joined: 21 Mar 2005 11:36

Re: TownCars AI

Post by Spedichef »

Well, this AI was never thought to make profits, just for having some eyecandy around. There are a few AIs out there, which build working and profitable networks. It would just take some work to implement the Streettraffic/Towncars-behaviour - but who has some time for it left?

However, once the AI dies, OpenTTD will re-create it a few months later. So you will always have eyecandy. I usually try to have only 3-5 cars per town, this will let the Ai live for some 60-80 years.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: TownCars AI

Post by Zuu »

If you want to avoid that TownCars or StreetTraffic goes bankrupt you can bring up the cheat window (Ctrl+alt+c) and change company to the ai and then give it lots of money. Then switch back to your company.

This does only work in single player though.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 4 guests