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

nb-au
Engineer
Engineer
Posts: 24
Joined: 10 Oct 2007 08:20
Location: NSW, Australia

Re: TownCars AI

Post by nb-au »

I get similar problems to that guy above except i get them on all maps i try to start :'(
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: TownCars AI

Post by Zuu »

The problem you have will not go away until StreetTraffic and/or TownCars gets updated.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Wasila
Tycoon
Tycoon
Posts: 1498
Joined: 15 Mar 2008 07:02

Re: TownCars AI

Post by Wasila »

What about:

You are not allowed to execute any DoCommand (even indirect) in your constructor, Save(), Load(), and any valuator.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: TownCars AI

Post by Zuu »

Wasila wrote:What about:

You are not allowed to execute any DoCommand (even indirect) in your constructor, Save(), Load(), and any valuator.
That is the thing that need to be addressed in the code when updating the AIs. If I confused you, I meant by updating, that the code has to be changed/updated with regard to the error you just mentioned.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: TownCars AI

Post by Zuu »

TownCars version 4

I've fixed the DoCommand error. So it should work again with recent OpenTTD versions. Version 4 is on BaNaNaS (the content download system) right now.

It is fixed by removing the usage of a custom valuator function and instead use the default valuate function. To do so both CanConnectToRoad and GetNeighbours4 need to not belong to the TownCars class. (static membership might work though, but have not tested that)
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
ruivilela
Engineer
Engineer
Posts: 16
Joined: 24 Jan 2007 10:22

Re: TownCars AI

Post by ruivilela »

Thanks for fixing that issue on towncars. I already missed that cars hanging around the scenario.

but some things: I have breakdowns active, and if that cars don't get maintenance, they will crash quite often, no?

and is there any renew of cars by new models? If I get to 2009, cars created in 1930 are the Model T (generic cars grf) .
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: TownCars AI

Post by Zuu »

Yes if you have break down on eventually the cars created by TownCars will break down very often.

Maintanence and renewal of vehicles are features available in the spin-off StreetTraffic, but not TownCars. StreetTraffic was created from version 3 of TownCars and has not been fixed but for that reason I have written quite clearly how I did to fix TownCars.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
ruivilela
Engineer
Engineer
Posts: 16
Joined: 24 Jan 2007 10:22

Re: TownCars AI

Post by ruivilela »

I notice a performance issue in a game I created. in a duo core P7530.

I had only 12 planes. And I started to created road infrastructure.

Cheated to get more cash. I created a map with 64x1024. Made a "motorway", with bridge/tunnel intersection, and the double road (each with a uniq way) covered about 800 tiles. 4 towncars AI with 200 cars each, there was around 25 towns on map. I connected all cities on that tiles. The towncars spreaded all over the map. Then I noticed there was a extra CPU usage.

It was running apparently normally, but I could not get the game faster (tab key) ... So I cut the double road on the middle of map, and I got a little better performance.

I reload the 4 AI and the performance issue disappeared. The game has problems with ~800 cars around?
Spedichef
Engineer
Engineer
Posts: 12
Joined: 21 Mar 2005 11:36

Re: TownCars AI

Post by Spedichef »

StreetTraffic v2

I played a bit around with Franks StreetTraffic-AI and added some code to it.

Major point is the extended AI lifespan. The AI checks its bank balance and will take only the loan it really need, so it does not run out of cash. Of course, one day the AI has taken all the loan and will die (, but not for lang, as Franks AI will start all over again). You can only save the AI from dying using the cheat console with ALT + C + CTRL, pause the game, change the company to “StreetTraffic”, add a lot of funds, change back to your company and enjoy a game with a never dying AI and its traffic.


Changes / additions to the code:

- make the AI playable again for OpenTTD nightlies after 0.7.3 release. The developers removed the GetHeight-Function and added a GetMaxHeight command.

- New formula 1 : 1000 for the car / inhabitants ratio instead of 1 : 100. This allows a "softer" car output in the cities.

- AI tells you more details in AILog Consol, what it does and how long it took etc, look in the AI Debug Console what's going on.

- AI tries not to die by bankruptcy by repaying the maximum loan and then adjusting the loan in steps. Depending on the AI settings the lifespan of the AI can be extend quite a lot. Feel free to do some experiments with it: 25 cities with 2 cars per 1000 inhabitants gives approx 65 years, 5 cities with 5 cars per 1000 inhabitants comes to approx 85 years, both scenarios built a maximum of 500 cars.

- Changed the AI config from „ticks“ to „days“, assume it is more "userfriendly" for the player.

- The „ticks per day“ (ingame ticks for one ingame day) can be amended to influence the vehicle purchasing rate, waiting times for next actions – this might be useful for player using the daylength patch.

I am not a coder, so the coding style might not look as it should be. This was just for some fun for myself and to honor Franks work on this eyecandy AI. If you find a bug, please post here, maybe someone will correct it. ;)

To use the AI you will need of course the "Generic Cars"-NewGRF available from the Content Download-Option in OpenTTD.

Thanks & best regards from Switzerland
Tim

(p.s. first post after joining the forum in 2005)
Attachments
StreetTraffic2.tar
StreetTraffic v2 AI
(57.5 KiB) Downloaded 469 times
Last edited by Spedichef on 27 Oct 2009 22:06, edited 1 time in total.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: TownCars AI

Post by Zuu »

Nice to see an update to the StreetTraffic spin off.

I think you should try to contact Frank and either get him upload your v2 to Bananas as a next version of the already existing StreetTraffic AI. If he don't want to upload things for you, you can possible arrange together with some of the devs with access to the Bananas database to move the ownership to you. Make sure you get in touch with Frank and get his opinion before contacting the devs. Also before contacting the devs, make sure you register an account on openttd.org if you have not done so yet. (If you have an old account on eg. bugs.openttd.org make sure you migrate that account to the central user system)

Edit: I guess KI means Komputer Inteligence or something similar in one of your four official languages in Switzerland, since you seam to have used "KI" in place of "AI" at some but not all places in your post.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Spedichef
Engineer
Engineer
Posts: 12
Joined: 21 Mar 2005 11:36

Re: TownCars AI

Post by Spedichef »

Yes, oops, KI is the abbreviation for "Künstliche Intelligenz" the translation of the english AI "Artificial intelligence". Amended it in my post for easy understanding. Thanks for noting.

Maybe Frank reads your post too, would appreciate if he likes the amendments too and upload in the online content archive. For now, I will wait a couple of days, action can be taken later.

Best regards
Tim
Spedichef
Engineer
Engineer
Posts: 12
Joined: 21 Mar 2005 11:36

Re: TownCars AI

Post by Spedichef »

Info for everyone, who is loading a game and getting an "rawin"-error message: this issue is known and discussed here.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: TownCars AI

Post by Zuu »

I can not comment on the StreetTraffic AI, but for TownCars I have tested it on both nightlies and 0.7.3 and it does not get that problem. Mostly because it does not use the rawin function. :-)
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Spedichef
Engineer
Engineer
Posts: 12
Joined: 21 Mar 2005 11:36

Re: TownCars AI

Post by Spedichef »

Hi Zuu

Yes, most likely. Just compiled the 17927 nightly, but I have still an AI crash. At least it is only Eyecandy and not a real competitor AI, and after reloading the AI, it starts all over to build its 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 »

Spedichef wrote:Hi Zuu

Yes, most likely. Just compiled the 17927 nightly, but I have still an AI crash. At least it is only Eyecandy and not a real competitor AI, and after reloading the AI, it starts all over to build its vehicles.
Which AI do you refer to, TownCars or StreetTraffic? Now that both AIs have ended up in the same thread it is quite helpful to be clear about which AI you refer to.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Spedichef
Engineer
Engineer
Posts: 12
Joined: 21 Mar 2005 11:36

Re: TownCars AI

Post by Spedichef »

I am referring to StreetTraffic AI.
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 »

Does TownCars/StreetTraffic have trouble with hilly maps normally? I'm playing a slightly modified CargoDist game, though the only road-affecting patch is Traffic Lights, I've made sure the generic cars grf is loaded, and made sure there's spaces for them to build depots, but they just can't seem to built one.
Spedichef
Engineer
Engineer
Posts: 12
Joined: 21 Mar 2005 11:36

Re: TownCars AI

Post by Spedichef »

Just speaking for StreetTraffic: With my Nightly 17927 the AI builds depots and cars on all maps generated by OpenTTD on the highest levels for hills, smoothness and the lowest for water.

Have you set the AI config from the main screen ? I could imagine, that if there are no entries set by the config dialogue into the openttd.cfg, the AI won't start to do anything, as it reads from the openttd.cfg all the building data (number of cities, numbers of cars, timeframe etc).

Please check and advise. You may also open the AI debug consol from the info menu and look up, what StreetTraffic does. It talks quite a lot :).
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'm using r17986, with the trunk-compatible cargodist patch from last night. I'll have to look to find out the exact revision.
I've checked the AI settings, they're set to use 0 cost/running cost RV's, which Generic Cars clearly provides - none of the other GRF's I have loaded modify that.
It also now seems that hilliness and roughness don't matter, in a new game, they've both managed to build in a single town on a 256x64 map, which has 5 towns on it.

I did also make sure the AI settings were set, TownCars is set to load first, followed a month later by StreetTraffic, and finally by PAXLink a year after.

As to the AI Debug, TownCars v4 just outputs "Failed to build depot" for all but the single town it managed to build in, then goes to sleep forever, in it's own words.

StreetTraffic (v1) is similar, it says "Failed to build depot: No cars will be build in this town!" and nothing else on the matter.
I did use the cheat dialog to change to playing as StreetTraffic, and built depots for it in the hopes it would use them, but it's ignored them.
Spedichef
Engineer
Engineer
Posts: 12
Joined: 21 Mar 2005 11:36

Re: TownCars AI

Post by Spedichef »

As I do not use the SVN and download the source only occasionally and compile for myself, I have only access to 17983 as latest revision from OpenTTD website. Just compiled the 17983 and all AI is still doing the job. I am afraid, I cannot help here. Maybe it is because of the cargodist patch.
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: Ahrefs [Bot] and 9 guests