Page 1 of 1

How do your AI's initially make money?

Posted: 01 Apr 2010 16:45
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

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

Posted: 01 Apr 2010 17:31
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.

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

Posted: 01 Apr 2010 17:59
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! :)

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

Posted: 01 Apr 2010 19:48
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

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

Posted: 02 Apr 2010 11:30
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!

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

Posted: 02 Apr 2010 11:45
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).

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

Posted: 02 Apr 2010 13:48
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.

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

Posted: 02 Apr 2010 15:17
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.

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

Posted: 03 Jun 2010 21:57
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