Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Wed Dec 19, 2018 2:33 am

All times are UTC




Post new topic  Reply to topic  [ 77 posts ]  Go to page 1 2 3 4 Next
Author Message
 Post subject: TownCars AI
PostPosted: Mon Mar 16, 2009 9:04 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4538
Location: /home/sweden
Hello,

Let me present TownCars, which is an AI that builds road vehicles that drive around randomly in towns.

Attachment:
TownCars_Screenshot.png
TownCars_Screenshot.png [ 96.25 KiB | Viewed 28928 times ]


In the AI settings there are a few options for defining which road vehicles it should built. The default settings are compatible with the Generic Cars GRF.

Attachment:
TownCars_Settings.png
TownCars_Settings.png [ 7.79 KiB | Viewed 28925 times ]


I have not tested with any other car GRFs, but for the AI to be able to distinguish them from buses, they need to either have free price, free running cost or zero capacity. And you need to in the AI settings specify which property that is zero in your GRF. It is also possible to make it only build road vehicles that carry passengers.

If you want this AI to stay alive for long time, you will have to use the cheat dialog to change player to the AI and give it some money for it to keep alive. Depends on the GRF of course, what costs it has to pay per year for the road vehicles.

From version 5 of this AI, it should no longer be selected as a random AI by OpenTTD, so in order to use it one must explicitly select it in the AI Settings. I believe this is the behaviour that most users want.

Dependencies
TownCars 5 requires SuperLib version 6 in order to function. If you download the AI via the in-game content downloader you will get this library automatically.


Attachments:
TownCars-5.tar [18 KiB]
Downloaded 1315 times

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Last edited by Zuu on Fri Mar 25, 2011 11:00 pm, edited 1 time in total.
Top
   
 Post subject: Re: TownCars AI
PostPosted: Mon Mar 16, 2009 10:22 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Wed Nov 07, 2007 10:44 pm
Posts: 9068
Location: Sol d
Wow, nice to see this actually implemented :)

Zuu, what about the idea, to give the AI a simple money maker (maybe also via an option), e.g to build one long-distance air route with a few planes (maybe 10) in order to make money and pay for the cars?

_________________
Image
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML


Top
   
 Post subject: Re: TownCars AI
PostPosted: Mon Mar 16, 2009 11:03 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Sun Jul 13, 2008 12:57 am
Posts: 313
Now that's a fun idea :)

_________________
Building Powargrid: a turn based strategy game


Top
   
 Post subject: Re: TownCars AI
PostPosted: Tue Mar 17, 2009 8:57 am 
Offline
Engineer
Engineer

Joined: Sat Jan 10, 2009 7:20 am
Posts: 126
Location: Paris, france
I totally agree with this AI. :D

Does he take city size into account ? I mean, dos he build more cars for bigger towns ?


Top
   
 Post subject: Re: TownCars AI
PostPosted: Tue Mar 17, 2009 9:51 am 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4538
Location: /home/sweden
Hypolite wrote:
I totally agree with this AI. :D

Does he take city size into account ? I mean, dos he build more cars for bigger towns ?

No, it doesn't. But it starts building in the biggest town. So that the biggest towns get populated with cars first.


planetmaker wrote:
Zuu, what about the idea, to give the AI a simple money maker (maybe also via an option), e.g to build one long-distance air route with a few planes (maybe 10) in order to make money and pay for the cars?

That was an idea I had, but didn't implement it right now.

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
   
 Post subject: Re: TownCars AI
PostPosted: Tue Mar 17, 2009 10:10 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Sat Aug 25, 2007 5:03 pm
Posts: 2185
Location: ~/
Maybe you could make it place 2-3 bus stops randomly in the city? It would make it some money, but the cities would start to grow..

I'll test the AI when I get home. :)

_________________
Image


Top
   
 Post subject: Re: TownCars AI
PostPosted: Tue Mar 17, 2009 12:50 pm 
Offline
Graphics Moderator
Graphics Moderator
User avatar

Joined: Mon Sep 13, 2004 1:21 pm
Posts: 5306
Location: The Moon
Nice. :)

What about intercity traffic? :P

_________________
Pikkarail.com blog | Patreon
Dev reference: NML Specs - NewGRF Specs - Savegame Internals - NoAi API - NoGo API


Top
   
 Post subject: Re: TownCars AI
PostPosted: Thu Mar 19, 2009 3:56 pm 
Offline
Transport Coordinator
Transport Coordinator

Joined: Thu Feb 07, 2008 2:06 pm
Posts: 378
Location: Glasgow
Way to go Zuu, I like the out of the box thinking you're applying here and in PAX. Mad props to you! :D

PikkaBird wrote:
Nice. :)

What about intercity traffic? :P

I think that is pretty much handled by not giving cars order they will simply drive around taking any road available. So if an other company builds a road which links cities I think it will go there as well.


Top
   
 Post subject: Re: TownCars AI
PostPosted: Thu Mar 19, 2009 6:16 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4538
Location: /home/sweden
Morloth wrote:
Way to go Zuu, I like the out of the box thinking you're applying here and in PAX. Mad props to you! :D


Not originally my idea with town cars, as this has been suggested for ages. But I was the first one to implement it. Or rather copy and paste parts of PAXLink and then link it together with a new main-loop. Fix bugs, add settings and fine tune. :) But thanks for your warm words anyways. :)


On bananas there is an update, that fixes the bug I mentioned in the PAXLink thread with depots/stations built wrongly next to sloping road with wrong slope direction. This was due to a return of an API function was treated as a boolean where it really was an integer with four possible values.

I couldn't resist to try 15 TownCars AIs, and found another issue, that if the AI failed to build the road bit it did still built the depot, resulting in an unconnected depot (for AIs you need do build the road before, as it is not built automatically as for players). Now it keeps trying as long as the error is "vehicle in the way". Same for building the depot, it will keep trying as long as the error is "vehicle in the way". However when removing the road stump after the depot is removed has always been retrying until it succeeds.

Oh, and naming has been changed so it now names the company #2, #3, .. when the name TownCars fails.


Attachments:
TownCars-v3.tar [24.5 KiB]
Downloaded 399 times

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Top
   
 Post subject: Re: TownCars AI
PostPosted: Sat Mar 21, 2009 9:33 am 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Wed Nov 07, 2007 10:44 pm
Posts: 9068
Location: Sol d
Zuu wrote:
Hypolite wrote:
Does he take city size into account ? I mean, dos he build more cars for bigger towns ?

No, it doesn't. But it starts building in the biggest town. So that the biggest towns get populated with cars first.

I like that proposal, though (possibly in addition to a max number of cars per town):
Attachment:
small_town.png
small_town.png [ 17.94 KiB | Viewed 28030 times ]
Attachment:
big_town.png
big_town.png [ 73.02 KiB | Viewed 28041 times ]

Clearly one would expect more traffic in the bigger town - maybe a factor as a setting with something like population / 100 as default and a max vehicle limit of 25 / town?

In any case it's great for the looks :) I asked Zephyris to upload his cars to bananas - so maybe it will then be even easier to get this running in a nice way. Might then be an idea to define that grf as a requirement for the AI :) - though of course it doesn't guarantee that it'll be activated in the newgrf settings then.

EDIT: Another thing which just popped my mind: it might be a bad idea to remove the depots, if vehicle_breakdowns = 1 - e.g. the cars will start to break down constantly, if they have not even a chance of being serviced once in a while. So... maybe leave the depot per town and send the cars for servicing every once in a while (if breakdowns are on only).

_________________
Image
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML


Top
   
 Post subject: Re: TownCars AI
PostPosted: Sat Mar 21, 2009 11:54 am 
Offline
Traffic Manager
Traffic Manager

Joined: Thu May 19, 2005 10:19 pm
Posts: 153
Location: Germany
Hi.

This AI is a really great idea. The towns look so much better with cars in them. But I would select the towns randomly and not by size. With some AIs (got a game with five of them running) the large towns are really crowded while the rest of the map is "dead".

In my game all AIs went bankrupt after about four years. That's why I thought about a money maker for the AI companies. A money maker could keep the company in business. That leads to my next question: Does the AI upgrade its vehicles to newer models? The AI removes the depot right after all cars hit the road. This way the old cars of the company will stay on the roads forever if the company makes profit. In this case there should be some vehicle upgrade logic.

Kind regards

Zombie

_________________
OpenTTD: OpenTTD-Wiki
OpenTTDCoop: Blog, Wiki
My favorite patches: cargo destinations, shared infrastructure


Top
   
 Post subject: Re: TownCars AI
PostPosted: Sat Mar 21, 2009 7:52 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4538
Location: /home/sweden
Thanks for your feedback.

Let me say like this, adding a airline between the two biggest towns might seam simple, but it requires quite some code additions. Upgrading/managing vehicles also requires quite some additional coding. Further improvements to this AI other than bug fixing is quite low on my list. Number of cars based on town size could happen as that is quite simple.


If anyone feel like doing improvements to this AI it is GPL 2, so just go ahead. You might want to fork it and use another name like TownCarsAdvanced so you can make a new entry on bananas for it.


For single player you can just open the cheat window and give it lot of money, and it will not bankrupt. For MP, yes then there can be a reason to have a MM. Or you can make a GRF that has free cars with zero running cost. Then the only cost will be to build the depots, and pay the annual company fee as well as the loan fee.

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
   
 Post subject: Re: TownCars AI
PostPosted: Wed Apr 08, 2009 1:18 am 
Offline
Engineer
Engineer
User avatar

Joined: Mon Apr 06, 2009 5:55 pm
Posts: 5
Skype: frank.juedes
Location: Houston, TX
Hi Zuu,

thank's for that inspiration! - I have taken your TownCars.3 and created StreetTraffic.1 from it.
Some of the suggested enhancements from here are implemented:

- The cars will be distributed more naturally, depending on the population of the town
- The cars will be distributed over a longer time, not all cars at once
- Only one depot will be built per city and those depots will not be destroyed, so that
- cars will be maintained
- cars will be re-newed
- If cars are being destroyed by crashes later, they will be replaced
- load/save is implemented
- more configurable options

I am planning to implement a simple money maker, depending on the configuration the StreetTraffic companies are running out of money within 5-10 years.
Any other suggestions welcome!

StreetTraffic is available from here (attachment) or on BaNaNaS.

Best regards from Texas, Frank/2

Zuu wrote:
Thanks for your feedback.

Let me say like this, adding a airline between the two biggest towns might seam simple, but it requires quite some code additions. Upgrading/managing vehicles also requires quite some additional coding. Further improvements to this AI other than bug fixing is quite low on my list. Number of cars based on town size could happen as that is quite simple.


If anyone feel like doing improvements to this AI it is GPL 2, so just go ahead. You might want to fork it and use another name like TownCarsAdvanced so you can make a new entry on bananas for it.


For single player you can just open the cheat window and give it lot of money, and it will not bankrupt. For MP, yes then there can be a reason to have a MM. Or you can make a GRF that has free cars with zero running cost. Then the only cost will be to build the depots, and pay the annual company fee as well as the loan fee.


Attachments:
StreetTraffic.1.tar [30 KiB]
Downloaded 401 times

_________________
In a world without walls and fences, who needs windows and gates?
Top
   
 Post subject: Re: TownCars AI
PostPosted: Wed Apr 08, 2009 5:56 am 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4538
Location: /home/sweden
I have not had time to test it, but it looks like you have done a decent work there!

You say you have implemented save/load, then I suggest you add the tag 'save/load' to BaNaNaS, so users know that you have done that. Even TownCars was marked with 'save/load', but with a note that it was only limited save/load support. (Ie don't go crazy and rebuild everything when the game is load again)

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
   
 Post subject: Re: TownCars AI
PostPosted: Wed Apr 08, 2009 7:28 am 
Offline
Engineer
Engineer
User avatar

Joined: Mon Apr 06, 2009 5:55 pm
Posts: 5
Skype: frank.juedes
Location: Houston, TX
Hi Zuu,

the AI works a different now. See the settings here:
Image
In the first phase the AI will select the 15 most populated towns from the game and will build a depot there. The relation between town_id and depot_tile will be stored into an AIList.

Then comes phase two, see the AI-Log here:
Image
The program enters an endless loop in which the list of towns, selected in phase one is processed and
[current population]/100 * [number of cars per 100 inhabitants per town]
are built in each town. After each car a configurable amount of time is slept, as well as after processing of each town and at the end of the loop.
Because this loop runs until the company runs out of money, crashed cars will be replaced in later phases of the game and if there are newer vehicle types available, the existing cars will be replaced with newe ones.

I save the list of town_ids and depot_tiles together with the game, because i don't know (yet!) how to recreate it after a game is loaded - and i wanted to test the load/save functions of the AI framework. :wink:

Here's an example of how it looks like (sorry for the german...)
Image
The depot in the center is the one owned by the AI.

Best regards from Texas, Frank/2

P.S. Currently i am using this AI to learn the API, maybe later this will end up in a new playing AI.
P.P.S Do you have a brief description of how i could build some random (bus-)stops in the towns to produce some money?

Zuu wrote:
I have not had time to test it, but it looks like you have done a decent work there!

You say you have implemented save/load, then I suggest you add the tag 'save/load' to BaNaNaS, so users know that you have done that. Even TownCars was marked with 'save/load', but with a note that it was only limited save/load support. (Ie don't go crazy and rebuild everything when the game is load again)

_________________
In a world without walls and fences, who needs windows and gates?


Top
   
 Post subject: Re: TownCars AI
PostPosted: Tue Apr 14, 2009 2:46 pm 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Fri Jul 11, 2008 2:46 pm
Posts: 168
Location: Cremona, Italy
that's a great idea!!! thanx lot :bow:
but, how i can instal it?

_________________
Code:
(>____<)

Image Image
----------------------------------------------------------------------------
i had got a cake >_<
Image


Top
   
 Post subject: Re: TownCars AI
PostPosted: Tue Apr 14, 2009 7:10 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4538
Location: /home/sweden
Use 0.7.0 or recent nightly.

* Click on the content download button in the menu.
* Select either TownCars or StreetTraffic from the list of downloads, by checking the download check box.
* Select GenericCars or other GRF containing city cars
* Click on download
* Close content download window

* Open NewGRF settings
* Add GenericCars to GRF list
* Close NewGRF settings

* Open AISettings
* Add TownCars/StreetTraffic to one of the slots (you need to set >= 1 AI players first)
* If you use GenericCars then TownCars and probably StreetTraffic default settings find the city cars. If you use another grf you need to fiddle with the settings (see my explanation in some of my posts above)
* Close AISettings

* Start a new game
* Wait until the AI starts. (by default 365 days +- some time)

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
   
 Post subject: Re: TownCars AI
PostPosted: Sun Apr 26, 2009 5:16 pm 
Offline
Engineer
Engineer

Joined: Wed Jan 24, 2007 10:22 am
Posts: 16
This looks quit nice! StreetTraffic looks more promissing than townCars for now (nightly builds)

At least I tested both and sometimes townCars seems sometimes to refuse to create cars. StreetTraffic is not in the Download content. Maybe ships (sails if there was such grf) going around map would be nice also :)

I notice that StreetTraffic build depots in other cities but it start to creates cars in only one depot.

Usually I flow the cars by creating inter-city roads, but for sure you already know that.

How to send money to other company without cheating? (I see the option but i don't know how to use it). My transport company financing road traffic :mrgreen:


Top
   
 Post subject: Re: TownCars AI
PostPosted: Fri Jul 10, 2009 5:48 pm 
Offline
Engineer
Engineer
User avatar

Joined: Sun Apr 13, 2003 7:18 pm
Posts: 26
Location: Portugal
A friend of mine tried out your AI on an old savegame with old AIs, using OpenTTD 0.7.1, and got some funky problems, I'm guessing the AI isn't designed to take over other AIs.
Still if it helps, here are some screenshots of the AI Debug messages:


Attachments:
PRV Transport, 16th May 1958#1.png [217.77 KiB]
Downloaded 120 times
PRV Transport, 16th May 1958#2.png [215.17 KiB]
Downloaded 93 times

_________________
Water train!
Top
   
 Post subject: Re: TownCars AI
PostPosted: Sun Jul 12, 2009 4:53 am 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Fri Dec 19, 2008 5:03 am
Posts: 313
Location: Indonesia
SupSuper wrote:
A friend of mine tried out your AI on an old savegame with old AIs, using OpenTTD 0.7.1, and got some funky problems, I'm guessing the AI isn't designed to take over other AIs.
Still if it helps, here are some screenshots of the AI Debug messages:

Have you tried that with the Nightly build? I think that OpenTTD would only load the same AI name.
Edit :: And of course StreetTrafic is not TownCars :D

_________________
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 77 posts ]  Go to page 1 2 3 4 Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2018 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2018.
Hosted by Zernebok Hosting.