How do your AI's initially make money?

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
kirky_D
Engineer
Engineer
Posts: 24
Joined: 25 Mar 2010 15:34

How do your AI's initially make money?

Post by kirky_D »

This is mainly a question to all the people out there with functioning AI's. But even if you don't have one please still chime in with suggestions :)

So the question:

How do your AI's make money at the very beginning of the game?

I ask because it seems to me that if you don't start making money quickly you'll either go bankrupt, or just sit there doing nothing because you don't have the money to.

Discuss. :P
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: How do your AI's initially make money?

Post by Zuu »

I don't do anything special to make money at the beginning other than starting to build something. In PAXLink this is not always successful due to it's lacking on the strategical level. (it can setup a air-link between two very close tows in the beginning if it is unlucky) And not to speak of TownCars, it does simply not make any money at all. :-p CluelessPlus on the other hand usually turn out if not good then at least not bad.

That said, PAXLink do start with buses in city mode (transporting within one city) which is fairly fail safe from construction point of view. However it doesn't generate a lot of money especially since bus stop stations are fairly expansive to have many of since each of them cost the same amount in maintenance as a railway station or airport.


I know some train building AIs start out with a simple single track link for one train to get started and then later continue with dual track constructions.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: How do your AI's initially make money?

Post by Morloth »

NoCAB uses the same technique all throughout the game:

1) Create a list of all possible connections (this can take quite a while on larger maps).
2) For a fixed time limit, create estimates per vehicle type for the above connection *.
* For big maps NoCAB is not able to create estimates for all of them, but it keeps a list of all calculated values and updates them every round.
3) Order the list according to some heuristic which tells you which connections are probably the best ones to build.
4) Create a better estimate of the best connections.
5) Select the best subset of all these depending on the money you can spend.
6) Build all these connections and return to 2.

That's all it does, and although it does help it quite smoothly (most of the time ;)) during the beginning stages of the game it does limit NoCAB a little bit later on as it needs to do a lot of work while it has millions of money to spend.

Hope it helps and good luck with you AI! :)
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: How do your AI's initially make money?

Post by Kogut »

It is nothing special, it uses the same main loop all the time:

Code: Select all

despair = 0;

for(true)
{
try to construct air connection with current despair;
try to construct truck connection with current despair;
try to construct cargo air connection with current despair;
if(ewerything failed)despair++;
else despair=0;
}
How despair works?
With despair 0 air module accepts only "ideal" connections. With higher also worse.
For example:

Code: Select all

minimal_distance = optimal_distance - 10 * despair
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
kirky_D
Engineer
Engineer
Posts: 24
Joined: 25 Mar 2010 15:34

Re: How do your AI's initially make money?

Post by kirky_D »

Thanks for your replies!

Some good suggestions there. The reason I ask is that I'm working on a train passenger only AI which probably won't make a lot of money. I thought about creating an air route to start with to make some money, but it is inconsistent with what I want the AI to do.

@Kogut: I like the notion of despair, for some reason it made me think of 'old gil' from the simpsons.

I think what I'll do is just have my AI get going and hope for the best, lol. If it works, great, if not I'll have to rethink!
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: How do your AI's initially make money?

Post by Kogut »

I think it may be better idea to start with bus ai. My first ai was intended to use trains, but it was far too complicated and ended with nothing. Anyway buses may be important when it is impossible to construct trains (too early, trains disabled for ai, too expensive (2cc or another newgrf) etc).
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 13 Jul 2008 00:57
Contact:

Re: How do your AI's initially make money?

Post by Michiel »

ChooChoo starts with 3 (should be configurable) single track, point-to-point lines with cheap trains, before switching to its network building mode. Usually that works, sometimes it doesn't.

Kogut, I like your "despair" idea, a variable scale of how much sub-optimality you're willing to accept.
Brumi
President
President
Posts: 921
Joined: 18 Jul 2009 17:54

Re: How do your AI's initially make money?

Post by Brumi »

SimpleAI does nothing extraordinary at the start of the game, only the minimum cash limit for building new routes is a bit lower until 5 connections are built (as far as I remember :wink: ). It tries to pick subsidies when they're available, and it chooses the construction site randomly when there are no subsidies available. Also deciding to pick a subsidy or not is random.
User avatar
Dustin
Transport Coordinator
Transport Coordinator
Posts: 272
Joined: 07 Dec 2005 19:22

Re: How do your AI's initially make money?

Post by Dustin »

Denver and Rio Grande doesn't have a special mode at the start. It sorts all the cargo types by how much they pay over an "average" distance route and mutliplies that by how much is produced at each place. Then it picks one of the top producers and tries to find a route to the nearest consumer, then the next nearest and so on. This usually means it creates shorter routes at the start and gets running. As it get's in it's own way, it tends to build the longer and longer routes.

It uses a weighted random function to pick the next producer in order to keep multiple instances from colliding every single time and to give the player a shot at the high producers without always snagging the biggest one right off the bat.

With the right selection of settings, Denver & Rio Grande can make a start on most maps. Even when it goes bankrupt, it will have leveled some key tiles and hopefully allowed the next company to succeed.

-D
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 1 guest