Boost city growth

OpenTTD is a fully open-sourced reimplementation of TTD, written in C++, boasting improved gameplay and many new features.

Moderator: OpenTTD Developers

User avatar
toholio
Traffic Manager
Traffic Manager
Posts: 216
Joined: 20 Dec 2004 00:54
Location: S37°56.286' E145°07.628'
Contact:

Post by toholio »

ConductorBob wrote:See I've tried all these methods and I haven't actually gotten any to work for me. I've tried...
Read what Darkvater and I wrote, it isn't speculation: Its what's in the code.

Basically, you need five stations all serviced at intervals of less that 20 days. Anything else is unnecessary.
sobo
Engineer
Engineer
Posts: 89
Joined: 13 Sep 2004 17:42
Contact:

Post by sobo »

busses are usually best because its easiest to get a busstop to be serviced every 20 days.
User avatar
Bernhard
Transport Coordinator
Transport Coordinator
Posts: 293
Joined: 11 Mar 2004 11:26
Location: 52º31'20"N 13º17'51"O

Post by Bernhard »

toholio wrote:
ConductorBob wrote:See I've tried all these methods and I haven't actually gotten any to work for me. I've tried...
Read what Darkvater and I wrote, it isn't speculation: Its what's in the code.

Basically, you need five stations all serviced at intervals of less that 20 days. Anything else is unnecessary.
i did! :D
City started in 1970 with 500 People, did nothing than add 5 Busstation, 5 busses serving all busstops.
10 years later the town had 1200 people.
User avatar
jacke
Director
Director
Posts: 533
Joined: 19 May 2002 14:47
Location: Sweden

Post by jacke »

Like some of you, I have a feeling that town growth is kinda fubared on bigger maps. I made a few tests, and it really feels like towns grow faster the smaller the map is, or maybe the lower the amount of towns is.

I have attached a few screenshots...
Attachments
I let this town grow for over 50 years on a 2048x2048 map, and sure it expands, but really slow....
I let this town grow for over 50 years on a 2048x2048 map, and sure it expands, but really slow....
bigmap1.png (136.03 KiB) Viewed 7020 times
Here's a town on a 2048x2048 map, which I let grow for 13 years with 5 bus stops.
Here's a town on a 2048x2048 map, which I let grow for 13 years with 5 bus stops.
bigmap2.png (86.63 KiB) Viewed 7020 times
Here's a screenshot of a town on a 256x256 map. I just let it grow for like ten years, with 5 bus stations.
Here's a screenshot of a town on a 256x256 map. I just let it grow for like ten years, with 5 bus stations.
smallmap1.png (109.04 KiB) Viewed 7020 times
User avatar
toholio
Traffic Manager
Traffic Manager
Posts: 216
Joined: 20 Dec 2004 00:54
Location: S37°56.286' E145°07.628'
Contact:

Post by toholio »

jacke wrote:Like some of you, I have a feeling that town growth is kinda fubared on bigger maps. I made a few tests, and it really feels like towns grow faster the smaller the map is, or maybe the lower the amount of towns is.

I have attached a few screenshots...
I mentioned the reason for this in my post explaining the workings of the town growth algorithm. Basically, the more towns on the map the longer the time between each town is "checked".
ConductorBob
Director
Director
Posts: 560
Joined: 21 Jun 2004 16:17
Location: Train station 1

Post by ConductorBob »

I think I found a way that seems to work for me. Pop an airport down on a town, and get a plane to just keep going to only that one spot. It made a few towns grow somewhat qucikly.
User avatar
toholio
Traffic Manager
Traffic Manager
Posts: 216
Joined: 20 Dec 2004 00:54
Location: S37°56.286' E145°07.628'
Contact:

Post by toholio »

ConductorBob wrote:I think I found a way that seems to work for me. Pop an airport down on a town, and get a plane to just keep going to only that one spot. It made a few towns grow somewhat qucikly.
Better yet: build five stations of any type and make sure they are each serviced at least once every 20 days.


OK, I'll stop repeating myself now... :wink:
User avatar
Arsenal
Traffic Manager
Traffic Manager
Posts: 227
Joined: 06 Jan 2004 21:25

Post by Arsenal »

The effects of population growth is definitely reduced with bigger maps.
In normal sized maps, it's easy to get towns at least 100,000.
in 9x9, you could get two towns to reach over 100,000 (though you might find that it will suddenly stop growing at a certain population.

I had one that reached about 140,000 and than it suddenly stopped expanding for no apparent reason. In fact, the town 'froze' for a few months. No new buildings, replacements or clearing at all. It was as if it was stuck in a time warp. When that town started being active again, that population instantly dropped to 110,00 before regrowing at a slower rate to 140,000 and cannot increase population any more.

I also had a go at a 10x10 map, and using the same methods i used for the maps above, I can't get a town to get beyond 40,000.

My conclusion: there must be some kind of "global" population limit, it is much more apparent with bigger maps.

I know people have looked at the code for the optimum town growth, (which I have observed to work) but I wonder if there is a global population limit?
User avatar
toholio
Traffic Manager
Traffic Manager
Posts: 216
Joined: 20 Dec 2004 00:54
Location: S37°56.286' E145°07.628'
Contact:

Post by toholio »

Arsenal wrote:My conclusion: there must be some kind of "global" population limit, it is much more apparent with bigger maps.
There isn't.

To quote myself from three posts ago:
toholio wrote: I mentioned the reason for this in my post explaining the workings of the town growth algorithm. Basically, the more towns on the map the longer the time between each town is "checked".
User avatar
Arsenal
Traffic Manager
Traffic Manager
Posts: 227
Joined: 06 Jan 2004 21:25

Post by Arsenal »

toholio wrote:
Arsenal wrote:My conclusion: there must be some kind of "global" population limit, it is much more apparent with bigger maps.
There isn't.

To quote myself from three posts ago:
toholio wrote: I mentioned the reason for this in my post explaining the workings of the town growth algorithm. Basically, the more towns on the map the longer the time between each town is "checked".
In which case, any way of speeding up the checks, or reducing the number of towns for a bigger map? I selected "low in number of towns option, and there were loads of them.
It is disproportionate, you might get somewhere about 12-15 towns in normal map size, but on 9x9, you get usually 4 times that. I know the map area increases by 4 as well, but I want to dissociate the link between the two.
If I select low towns, it should mean and remain a low numbers of towns, rather than maintaining a low "density" of towns in an area size.

I'm not sure if that's clear, but hopefully it is.
Cadde
Transport Coordinator
Transport Coordinator
Posts: 290
Joined: 07 Oct 2004 12:51

Post by Cadde »

Okay... To actually give a complete explaination of all posts in this topic.
(Though correct me if i missed something)


Town growth is based on the number of active stations

Use 5 stations of any type and have it serviced every 20 days or less.
Less than 5 stations and the town will grow slower!
More than 5 stations and all you will do is transport more passengers within that town.

That's what the code says anyways nothing fancy about it...


The more towns on a map the slower they all grow

TTD is a game and therefore it uses the CPU to compute all growths.
It makes one calculation every 26 millisecond, this is called a "TICK".
With less towns the game can make more calculations every year for example resulting in faster growth for all towns.
Also i suspect that the more trains, buses, Aircraft and ships you use the more CPU time is used for theese vehicles therefore reducing the growth rate of town due to less TICKS being produced.
Though that is just a suspicion!
One thing more about TICKS and CPU time:
If you have a slow machine the CPU cant handle the TICK interval properly... Use a faster machine and see if you can notice a change...
NOTE: As someone mentioned earlier in this topic his town just stopped growing when he reached 140,000 people.
The ammount of vehicles combined with the ammount of towns might be consistant with this sudden halt...
The CPU may be given less time to actually grow the town as fast as before.
Also funding new buildings is probably less effetive at this stage...


If you really want something out of your towns new growth

You can build a Feeder service, mening all buses go from a bus stop to a train station and unload passengers there with the new unload feature and therefore increasing the ammount of passengers a train station have...
By doing so you can get more cash because trains handle more passengers at a time and travel longer distances faster than busses.
As far as i know the buses wont make any money but it's more profitable in the long time anyways.

Town growth is defined by the number of houses

Try to remodel a towns infrastructure so theres more room for houses.
Roads dont produce passengers unless there are homeless living on the streets. :roll:
As mentioned, 2x8 tiles should be optimal so therefore build roads every 4th square and make connections between them every 10th square to leave 2x8 rectangular areas to allow a town to build as many houses as possible!

Start off with a SMALL town

Dont start with the largest town you can find because if you start demolishing every house and road to remodel a town to have 2x8 areas to build houses on the local authority will be bad.
Instead start with a small town.
remodel it totally but leave as many houses as possible and build up a road network consistant with 2x8 rectangular areas and somewhere near the center excavate enough land to be able to place a train station the size of say 8 in length and with 6 tracks...
Planning ahead is good so that you wont get an overcrowded station.
(Remember the Feeder service i mentioned?)
The reason for building your station in a excavated area is because you should tunnel your way out of the town leaving more room for the town to grow.
You could choose to build a large hill in front of your station instead so that trains dont have to slow down to climb a slope, it's up to you!


Fund new buildings every 3 months

Because of the way TTD works you should only fund new buildings every three months, smaller intervals than that is somewhat a waste of money.
Also keep in mind that the more houses a town already has, the less effective is the funding of new buildings.



I might have missed out on something but that should cover the most of it! (Comments PLEASE!)

//CADDE
User avatar
LordOfThePigs
Route Supervisor
Route Supervisor
Posts: 435
Joined: 01 Jul 2004 10:28
Location: Jura/Switzerland

Post by LordOfThePigs »

Cadde wrote: The more towns on a map the slower they all grow

TTD is a game and therefore it uses the CPU to compute all growths.
It makes one calculation every 26 millisecond, this is called a "TICK".
With less towns the game can make more calculations every year for example resulting in faster growth for all towns.
Also i suspect that the more trains, buses, Aircraft and ships you use the more CPU time is used for theese vehicles therefore reducing the growth rate of town due to less TICKS being produced.
Though that is just a suspicion!
One thing more about TICKS and CPU time:
If you have a slow machine the CPU cant handle the TICK interval properly... Use a faster machine and see if you can notice a change...
NOTE: As someone mentioned earlier in this topic his town just stopped growing when he reached 140,000 people.
The ammount of vehicles combined with the ammount of towns might be consistant with this sudden halt...
The CPU may be given less time to actually grow the town as fast as before.
Also funding new buildings is probably less effetive at this stage...
I'm affraid this has nothing to do with the speed of your computer. Ticks normally happen every 26 ms (I didn't check it by myself, but I'll trust you on that one), but if your computer is slow enough, the interval may get larger. A OTTD game day is normally about 2 seconds long. This is actually figured out by the game by checking the number of ticks since the beginning of the game, which means that days always contain the same amount of ticks, which implies that a Tick is never dropped. During the same amount of game time, you towns will grow by the same amount, regardless of your CPU (I'm really talking about OTTD days, and not actual real seconds).

The problem is that on each tick, OTTD selects a fixed amount of random town(s) to grow. Obviously, the more towns you have, the less often each individual town grows.

Apparently town growth is broken anyway, the title of #openTTD says :
#openTTD wrote:0.4.0 feature freeze. We should fix bugs now | Who broke the town growth?
Sometimes I'm told "Brilliant"...
Sometimes I'm told "Charming"...
And Often I'm told "Shut Up"!
User avatar
toholio
Traffic Manager
Traffic Manager
Posts: 216
Joined: 20 Dec 2004 00:54
Location: S37°56.286' E145°07.628'
Contact:

Post by toholio »

LordOfThePigs wrote: The problem is that on each tick, OTTD selects a fixed amount of random town(s) to grow.
I'm fairly certain the towns are serviced one per tick in a round robin fashion.

The relevant code is in OnTick_Town() in town_cmd.c

OnTick_Town() is called only once from CallLandscapeTick() in landscape.c

Code: Select all

void OnTick_Town(void)
{
	uint i;
	Town *t;

	if (_game_mode == GM_EDITOR)
		return;

	i = _cur_town_ctr;
	if (++_cur_town_ctr >= GetTownPoolSize())
		_cur_town_ctr = 0;

	t = GetTown(i);

	if (t->xy != 0)
		TownTickHandler(t);
}
The simplest way to fix this problem would be to scale the number of towns checked using ScaleByMapSize().

Something like:

Code: Select all

void OnTick_Town(void)
{
	uint i;
	Town *t;
	int remaining;

	if (_game_mode == GM_EDITOR)
		return;

	remaining = ScaleByMapSize( 1 );
	do
	{
		i = _cur_town_ctr;
		if (++_cur_town_ctr >= GetTownPoolSize())
			_cur_town_ctr = 0;

		t = GetTown(i);

		if (t->xy != 0)
			TownTickHandler(t);
		
		remaining--;
	} while( remaining > 0);
}
Should do the trick but I'm not near a compiler to check.
Cadde
Transport Coordinator
Transport Coordinator
Posts: 290
Joined: 07 Oct 2004 12:51

Post by Cadde »

Yeah the obviuos thing vould be that a TICK is a looping feature...
Therefore cpuspeed is not an issue but i still woundered if ticks could be missed out due to slow computers but you prooved me wrong...

so eaven with more vehicles and industries on the map it still does everything in a complete loop not skipping anything to preserve gamespeed eaven if i had 500 cities and 5000 trains?
I was thinking of something like multitasking where it's more important to preserve visual stuff and control trains than it was to actually check if a town should grow every 26 ms...

I got 26 ms from that linked page i think... If you are intrested look for links because im to tired right now to find it again... :(

//CADDE
User avatar
toholio
Traffic Manager
Traffic Manager
Posts: 216
Joined: 20 Dec 2004 00:54
Location: S37°56.286' E145°07.628'
Contact:

Post by toholio »

Cadde wrote: so eaven with more vehicles and industries on the map it still does everything in a complete loop not skipping anything to preserve gamespeed eaven if i had 500 cities and 5000 trains?
You seem to have misunderstood slightly. OpenTTD doesn't loop through every town each tick. It only checks one town each tick (trains and industries may be different, check the code).

So, no, it doesn't skip anything if you have more cities because you can't skip something when you've only got one to work with.
Cadde
Transport Coordinator
Transport Coordinator
Posts: 290
Joined: 07 Oct 2004 12:51

Post by Cadde »

toholio wrote:
Cadde wrote: so eaven with more vehicles and industries on the map it still does everything in a complete loop not skipping anything to preserve gamespeed eaven if i had 500 cities and 5000 trains?
You seem to have misunderstood slightly. OpenTTD doesn't loop through every town each tick. It only checks one town each tick (trains and industries may be different, check the code).

So, no, it doesn't skip anything if you have more cities because you can't skip something when you've only got one to work with.

Never mind, we are on diffrent mind tracks here... thats not important anyways...

I made a test map with one big town and one small in editor...
The big one was remodeled from the start with some 2x8 squares
and i restricted it be be exactly 20x20 square building four 20 in length stations like a box... So the city cannot expand beyond 20x20.
The smaller one was a default small town in editor.

As i added 4 busstations around the center of the town and one next to the box shaped train station and ran 8 buses through theese stations the city first dropped by 1000 people (originally around 10,000)
but i think that is expected since the town immedietly started building new houses and older houses where removed.
I waited a year in fast forward mode and the town had grown to 14,000 people.

Then i modeled my smaller town to have only 2x8 blocks by adding roads every 4th square in depth and 10th square in length.
Without adding any transport the town started building 2 houses.
Then i placed 4 busstations in the centre and a 20 squares long trainstation about 12 squares from the centre, i also built my fifth bus station in connection to my train station.
My train station did not accept anything at this point but i ran 4 buses in a loop around the centre of the town and it litterally exploded...
First 6 houses were constructed and then about 8 more.
the small town had 100 people originally but 6 months later it had 800.
Then my train station accepted passengers so i built a train with 3 SH 40 locos and 37 passenger carriages... (1,470 passengers every run)
i ran that train from the big city to the small city and nothing happened instantly but after 3 months or so the small town had about 1500 people.
Then i funded new buildings and the stupid town started building a lot of roads to destroy those 2x8 blocks so i had to remove any road they added.

Ok after 5 years of play my 20x20 square town now had 21,342 people in it (from 10,000).
And my smaller town (now big) had 18,547 people.

Conclusion: You can make towns grow.
but the more room a town have to grow in the faster it will grow (duuh).
and it's really better to start with a small town around 100 pop than a big one where everything is kind of messed up and takes some demolishing to build stuff in. (I tried to demolish things in the big town to place bus stops and local authority refused me to do anything after three bus stops so i made room for all stops in the editor in advance)

EDIT: I ran the game for anoter 5 years for fun and i found out a very special connection.

My 20x20 square town actually dropped by 5000 people.
And i think it's related to my stations ratings dropping.
Because i have about 2,000 passengers per bus station and ratings are POOR...

//CADDE
User avatar
toholio
Traffic Manager
Traffic Manager
Posts: 216
Joined: 20 Dec 2004 00:54
Location: S37°56.286' E145°07.628'
Contact:

Post by toholio »

Cadde wrote: EDIT: I ran the game for anoter 5 years for fun and i found out a very special connection.

My 20x20 square town actually dropped by 5000 people.
And i think it's related to my stations ratings dropping.
Because i have about 2,000 passengers per bus station and ratings are POOR...
I doubt it. The stations rating isn't used in determining the town's growth. A more likely explanation is that you somehow didn't service at least five stations in the days leading up to the town growth being recalculated.
Cadde
Transport Coordinator
Transport Coordinator
Posts: 290
Joined: 07 Oct 2004 12:51

Post by Cadde »

toholio wrote: I doubt it. The stations rating isn't used in determining the town's growth. A more likely explanation is that you somehow didn't service at least five stations in the days leading up to the town growth being recalculated.

Nope my buses ran like crasy... Every bus stop had a bus every 3 - 5 days...

The population just dropped when i unpaused the game and never got to 20,000 again...
By the way my once a small 100 people town grew to 48,000 then i played multiplayer with my brother instead...

I had only two towns... thats why my originally 100 people town grew to 48,000 in 10 years

I only trasnported passengers... no goods or anything...
Horse
Transport Coordinator
Transport Coordinator
Posts: 325
Joined: 10 Sep 2004 20:25

Post by Horse »

You ar all talkin about growing the city.

but in my games each town i connected are only schrinking.
after many years a big city is schrinked to a village with only empty roads.

transport systems are so toxic people die like a middle century epidimic.

A connected town schrinks.
Horse
Transport Coordinator
Transport Coordinator
Posts: 325
Joined: 10 Sep 2004 20:25

Post by Horse »

In the older transport tycoon it was a lot different than this.
Post Reply

Return to “General OpenTTD”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 9 guests