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

openttd_rulez
Traffic Manager
Traffic Manager
Posts: 173
Joined: 06 Jun 2010 01:42
Location: MALAYSIA

Re: TownCars AI

Post by openttd_rulez »

why do you even DARE to make such an AI? It does not do anything and it keeps going bankrupt and being replaced in perpetual motion at least 3 times a year on my games! But some kids who just love to see some "Your'e The Winner" message still use this AI because "they don't do much".

PS does it support LRVS?
Signature last edited by OPENTTD_RULEZ, edited Image times in total.

ImageImage
ImageImage
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: TownCars AI

Post by Kogut »

That ai is not designed to earn money in efficient/inefficient way. It is designed to pollute cities with small vehicles.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
openttd_rulez
Traffic Manager
Traffic Manager
Posts: 173
Joined: 06 Jun 2010 01:42
Location: MALAYSIA

Re: TownCars AI

Post by openttd_rulez »

yeah, and risk the city road traffic (buses trucks & trams) being clogged, delayed or even the game crashing due to processor overload.
Signature last edited by OPENTTD_RULEZ, edited Image times in total.

ImageImage
ImageImage
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 AI (I can't speek of StreetTraffic as that's not my AI) has a property set that means that OpenTTD will never select it by random. So if you decided to explicitly use this AI, then you better read the description than complaining about it. It says in the description what the purpose of the AI is.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: TownCars AI

Post by planetmaker »

openttd_rulez wrote:yeah, and risk the city road traffic (buses trucks & trams) being clogged, delayed or even the game crashing due to processor overload.
Yes, s*** happens.

Especially mind what Zuu tells you. Go and play your game as you like. But PLEASE stop the whining that there are people who play it differently than you and that people develop extensions which suit their playing style and not yours.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: TownCars AI

Post by Yexo »

I second planetmaker's post. And when you do want to complain about something, don't use language like
why do you even DARE to make such an AI?
Remember that all AIs you can find in this forum are created in peoples free time (same holds for openttd itself and the newgrfs you can find on various places).
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 5

I noticed that TownCars 4 did not tell OpenTTD that it should not be selected as a random AI. I believe this is wrong behaviour for a non-competitive AI and has therefore released this update which adds the following code to info.nut:

Code: Select all

	function UseAsRandomAI()  { return false; }
Some strings has been tweaked here and there. I've also removed some redundant code and used my Helper class from SuperLib (version 6) instead of including an old version of it directly in the AI.

Download
Version 5 of this AI for manual download can be found in the first post. (there you also find a link to SuperLib)
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
laserdog
Engineer
Engineer
Posts: 12
Joined: 27 Mar 2011 03:12

Re: TownCars AI

Post by laserdog »

town cars is a good player with busses
KeldorKatarn
Transport Coordinator
Transport Coordinator
Posts: 274
Joined: 13 Apr 2010 21:31

Re: TownCars AI

Post by KeldorKatarn »

Question: How does this AI replace its vehicles with newer models in later years? I'm guessing it build depots again but how do the vehicles get to these depots? Does it trust in the standard servicing behavior or does it order them into the depot?

The reason I'm asking is pretty severe: I just profiled an old savegame of mine, where I used this AI. The AI causes a massive slowdown of the game once the cars try to service. The "Road Vehicle Find Depot" function uses 83% of the frame time at that point, since the vehicles are unable to find one they constantly trigger the pathfinder.

I am trying to work around this by patching my personal code to never service or breakdown vehicles with 0 running costs and 0 initial cost. however if you do not order your vehicles do a depot specifically this would prevent the AI from upgrading them.

Can you comment on this?
KeldorKatarn
Transport Coordinator
Transport Coordinator
Posts: 274
Joined: 13 Apr 2010 21:31

Re: TownCars AI

Post by KeldorKatarn »

FYI: Fixed in on my end by adding this to bool Vehicle::NeedsServicing() const once the inital service check returns true:

Code: Select all

	/* Do we even have any depots/hangars */
	uint rail_pices = 0;
	uint road_pieces = 0;

	for (uint i = 0; i < lengthof(c->infrastructure.rail); i++) rail_pices += c->infrastructure.rail[i];
	for (uint i = 0; i < lengthof(c->infrastructure.road); i++) road_pieces += c->infrastructure.road[i];

	if ((this->type == VEH_TRAIN && rail_pices == 0) ||
		(this->type == VEH_ROAD && road_pieces == 0) ||
		(this->type == VEH_SHIP && c->infrastructure.water == 0) ||
		(this->type == VEH_AIRCRAFT && c->infrastructure.airport == 0)) {
			return false;
	}
That solves the problem I think and speeds up the game back to the original performance, despite TownCars
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: TownCars AI

Post by Zuu »

This AI was written to spawn town traffic. Having depots staying around that cost maintenance did not fit into that picture. Thus the AI removes the depots and never add them back. The problem hat you mention of a high performance cost due to not having any depots was not known when the AI was written. Thanks for bringing it up thought. With that in mind it may be better to leave the depots if servicing is enabled in advanced options and instead be more clear that users should use cheats to make the company survive.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
KeldorKatarn
Transport Coordinator
Transport Coordinator
Posts: 274
Joined: 13 Apr 2010 21:31

Re: TownCars AI

Post by KeldorKatarn »

Well... it would already help if the AI didn't set service to "every 150 days"

if it set them to some percent of the original reliability the cars would probably never ask for service, since from what I can see, the NewGRF sets with vehicles for this to use don't decay...
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: TownCars AI

Post by Zuu »

Im quite sure that the AI does not touch that setting. Eg it uses the default value whatever it appears to be.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
KeldorKatarn
Transport Coordinator
Transport Coordinator
Posts: 274
Joined: 13 Apr 2010 21:31

Re: TownCars AI

Post by KeldorKatarn »

Hmm, pretty sure I didn't use that setting as my default. In any case, the AI should reset it to a percentage based value.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: TownCars AI

Post by Zuu »

Actually, reviewing the API, I can't see any option for AIs to change the service frequency settings. (Vehicle API, Game Settings API. AIs can toggle auto renew here: AICompany)
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
KeldorKatarn
Transport Coordinator
Transport Coordinator
Posts: 274
Joined: 13 Apr 2010 21:31

Re: TownCars AI

Post by KeldorKatarn »

Ah well... btw, when and how does your AI replace the vehicles with newer models?
krinn
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 29 Dec 2010 19:36

Re: TownCars AI

Post by krinn »

Here are patched files of towncars using toylib (i clean my personal version to make it, well, fine for everyone).

Changes:
- bump to a v6
- Add toylib to pay expenses
- Add option to disable toylib usage (but toylib is enable per default)
- Alter all info.nut boolean to be INGAME swappable (so you can change your mind).
I hope some will enjoy.
Attachments
info.nut
(3.13 KiB) Downloaded 147 times
main.nut
(13.09 KiB) Downloaded 138 times
User avatar
einsteinyh
Engineer
Engineer
Posts: 46
Joined: 15 Feb 2016 01:22
Location: Bogotá

Re: TownCars AI

Post by einsteinyh »

Is anybody maybe maintaining this AI? It cannot buy depots with NRT :(

Image
Attachments
Captura.PNG
Captura.PNG (60.1 KiB) Viewed 1299 times
User avatar
justaplayer
Engineer
Engineer
Posts: 40
Joined: 12 Dec 2020 12:37

Re: TownCars AI

Post by justaplayer »

einsteinyh wrote: 10 Jul 2021 06:48 Is anybody maybe maintaining this AI? It cannot buy depots with NRT :(

i have the same problem with the DROP Road set.

Just use the company changing cheat to create vehicles (i know that its not automatic but at least the you have cars , Right?)
Its just better than none
User avatar
Firrel
Engineer
Engineer
Posts: 118
Joined: 13 Aug 2019 17:06

Re: TownCars AI

Post by Firrel »

einsteinyh wrote: 10 Jul 2021 06:48 Is anybody maybe maintaining this AI? It cannot buy depots with NRT :(
Check out CityLifeAI.
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

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