[Patch] InnerCity

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
jackyf
Engineer
Engineer
Posts: 11
Joined: 01 May 2013 12:35

[Patch] InnerCity

Post by jackyf »

Hello,

So some time ago I was enjoying OpenTTD, namely, building a bus network in a town, and, as usual, got a circle road with double-decker "road trains" servicing half of the city population with 5 or 6 stations. This happens because towns, and especially big cities get very packed. And then I thought, what if towns could be more widespread so interesting things may happen for "inner city" play (or "wide city", or "Finnish dream", pick the one you like)? So widespread that it becomes feasible to build longer bus routes, and employ metro lines and even local trains?

Here I want to share what I've coded to hear what people think about the idea -- your feedback is welcome!
middle-size town, front picture
middle-size town, front picture
kokkola-trasport-small.png (699.82 KiB) Viewed 7656 times
Couple more pictures in attachments. I included full-sized ones to show some variety, please tell if that's not appropriate.

Details what the patch does:
- The patch is stateless (albeit some calculation caching) and therefore IIUC savegame-compatible with trunk.
- The patch modifies where and what buildings are placed in a town.
- The patch also reduces 4 times (approximately) passenger and mail production, to accomodate for house number increase.
- Towns do not build roads. Due to the rating system (see below) in most areas there however will be some space so you can build a curvy road with only few manual demolishings.
- When a town grows, (subset of) possible places are checked and a rating ("attractiveness") is calculated for each tile. If there are (usually, there are) places with enough positive attractiveness, houses are placed there.
- Only a small part of tiles is estimated on each grow step, so things tend to go to "good" places but occasionally will also be built in not so attractive places.
- Towns also can demolish buildings if their rating drops to a negative.
- Ratings are affected by distance from the town center, infrastructure nearby and houses nearby.
- Buildings prefer to be closer to the center.
- Buildings prefer to be close to water, stations, roads/rails, trees.
- Buildings prefer to be not very close to industries.
- Buildings like if nobody lives several tiles nearby.
- However, buildings like if there are population in a larger area, however also not too much.
- Building selection is directly affected by area population. High towers are unlikely in the city outskirts. For not so big cities, there will be no high towers even in the center. Average house population will slowly grow as a town grows.
- Over time, for middle- and big-size cities (roughly 10000-30000+ in my games, depending on many things) houses will form clusters if possible. Their average size will be same (in a single point of time), but exact place, size and population will be semi-random and naturally affected by all rating changes. A cluster is just of group of buildings which got near by rating and probability "pressure", they are dynamic and may shrink, grow, move, split, merge or half-merge. An average cluster radius also grows when city grows.
- Buildings prefer to be either near to some cluster ("local") center or far from any clusters.
- Area/cluster calculation results are cached for 7 game days. Without that, (on my computer) a city of 100000+ growing every day starts to lag.
- For town tiles, a tile information window will, in addition to normal things, show a rating, a house zone and a preferred building population in that area.
- ... maybe I forgot something, but I think this is it.

Try this patch with some city growing script (e.g. RCG or City Controller). Adjust, if possible, their pax/mail expectations to 4-8 times smaller if they look on town sizes. Or just start a game, choose a city, build some stations, set town growth rate to high, press fast-forward and watch a small village grow to become a 50000-, or 200000-, or perhaps even 1000000-sized urban beasts, swallowing rivers, lakes, industries and small towns nearby (that's how I got one of the pictures attached). Have fun!

The patch itself is of "proof-of-concept" quality -- ad-hoc printfs, hardcode, things dirty or out of place, you name it. If there is an interest, I'll be happy to improve it -- clean up and provide parameters for main relations, or maybe more rating ideas.

Finally, I want to thank OpenTTD contributors which provided code, graphics, translations, wiki and everything else. Particularly, the patch wouldn't been possible to write without using already present and clearly named functions (to work with maps, tiles, houses, towns). Even if the patch doesn't get anywhere, I had a lot of fun coding and playing :)
Attachments
Salo Transport, 1. 03. 1995#1.png
large city, world overview
(963.34 KiB) Not downloaded yet
Salo Transport, 1. 03. 1995#2.png
large city, one part zoomed
(2.78 MiB) Not downloaded yet
Last edited by jackyf on 11 Jan 2016 20:37, edited 3 times in total.
jackyf
Engineer
Engineer
Posts: 11
Joined: 01 May 2013 12:35

Re: InnerCity

Post by jackyf »

And the code.
Attachments
inner-city-20160110-1.patch
(19.24 KiB) Downloaded 217 times
User avatar
supermop
Tycoon
Tycoon
Posts: 1104
Joined: 21 Feb 2010 00:15
Location: Fitzroy North - 96

Re: [Patch] InnerCity

Post by supermop »

I was just thinking that I would love to see something just like this! I'd love to try it sometime, if you have a windows binary.
jackyf
Engineer
Engineer
Posts: 11
Joined: 01 May 2013 12:35

Re: [Patch] InnerCity

Post by jackyf »

No unfortunately, since I don't use/have Windows.

Maybe someone else who applied the patch can post a binary.
Eddy Arfik
Transport Coordinator
Transport Coordinator
Posts: 260
Joined: 09 Apr 2014 11:10

Re: [Patch] InnerCity

Post by Eddy Arfik »

Interesting concept towards town placement, but I don't really like the reduction in passenger generation. There are already other ways to get same effect with NewGRF building set or daylength patch, they probably won't work well with this patch. Also I have had no trouble getting 1million+ cities with standard town growth style (see my screenshot thread) . That said I might play a game or two with this and see how it turns out.

Anyway here is a Windows 64-bit binary

edit: replaced broken binary with working build
Attachments
OpenTTD-r27498_InnerCityPatch-win64.7z
(5.33 MiB) Downloaded 171 times
Last edited by Eddy Arfik on 17 Jan 2016 02:51, edited 1 time in total.
jackyf
Engineer
Engineer
Posts: 11
Joined: 01 May 2013 12:35

Re: [Patch] InnerCity

Post by jackyf »

Thank you for comments and the published binary!

I took a look at your thread, and yeah -- no idea how you achieved it, but I see that figuring out how make e.g. 'suburb - city center' and 'suburb - suburb' bus lines profitable might be quite boring for your playing level :)

As for NewGRFs, I didn't find anything modifying passenger production. Which building sets could I test?

I partly understand your point about passenger generation. I somehow feel though that significant reducing "base" pax/mail production goes hand-in-hand with a (certain) game play in a wider city. At least from personal experience, even in standard-layout cities I get very quickly to the point that for most bus stations I buy many tens of fastest double-deckers which can barely serve 4 or 5 stations within, say, 12x12 tile square. And still making loads of money no matter how I placed my routes -- an influx is just so high. If we expand that so same number of passengers has to be transported in a 30x30, or 50x50, or 80x80 tile square, any transport one'd use will need significantly more time to travel and therefore even more units which I wouldn't even know where to place if my roads are already stuck. When I was balancing the patch on the 200'000-sized city, even after 16x-decrease I had fairly loaded metro lines in the center. It might be of course that I just don't know the tricks to handle that load :)

My area of inspiration is a typical nordic town/region, where the problem is opposite -- shortage of passengers. A bus on a 30-stop curvy route with an average of 1 passenger per stop is considered pretty well-filled. I also aim for variety of service levels and models within same town.
arikover
Route Supervisor
Route Supervisor
Posts: 466
Joined: 15 Jun 2007 09:27
Skype: madchimiste
Location: Berlin, Deutschland

Re: [Patch] InnerCity

Post by arikover »

jackyf wrote:As for NewGRFs, I didn't find anything modifying passenger production. Which building sets could I test?
Town and Industries Houses does that (a bit). And Pineapple Houses will do that too when it comes out, as far as I understood.
arikover
Route Supervisor
Route Supervisor
Posts: 466
Joined: 15 Jun 2007 09:27
Skype: madchimiste
Location: Berlin, Deutschland

Re: [Patch] InnerCity

Post by arikover »

Sorry for double posting!

Thank you Eddy Arfik for the windows64 binary. I get an error message about 'libfreetype-6' library not being installed (see attachment) when I launch it. Am I the only one, or is this my fault?
Attachments
error-libfreetype-6.png
error-libfreetype-6.png (19.78 KiB) Viewed 6883 times
User avatar
supermop
Tycoon
Tycoon
Posts: 1104
Joined: 21 Feb 2010 00:15
Location: Fitzroy North - 96

Re: [Patch] InnerCity

Post by supermop »

I get the same error.
Eddy Arfik
Transport Coordinator
Transport Coordinator
Posts: 260
Joined: 09 Apr 2014 11:10

Re: [Patch] InnerCity

Post by Eddy Arfik »

arikover wrote:Thank you Eddy Arfik for the windows64 binary. I get an error message about 'libfreetype-6' library not being installed (see attachment) when I launch it. Am I the only one, or is this my fault?
Sorry, it seems the binary I posted before was broken, I only tested it quickly on my system. I've edited the post above with what should be a working copy (tested on 3 different computers)
arikover
Route Supervisor
Route Supervisor
Posts: 466
Joined: 15 Jun 2007 09:27
Skype: madchimiste
Location: Berlin, Deutschland

Re: [Patch] InnerCity

Post by arikover »

Eddy Arfik wrote:I've edited the post above with what should be a working copy (tested on 3 different computers)
Thank you very much for that quick fix, it runs correctly now!
lukasz1985
Route Supervisor
Route Supervisor
Posts: 429
Joined: 27 Mar 2013 08:58
Location: Strumien
Contact:

Re: [Patch] InnerCity

Post by lukasz1985 »

This patch would be perfect if only the city was able to build roads. I know this brings a lot of complexity into consideration, but I guess, that if you were into it, you could use the simplest solutions out there: like following the top-rated tiles, and looping back to the start to avoid dead ends, or at the bottom line - just draw rectangular blocks around the most populated areas.

EDIT: If you are really amibtious about it - you could also use my concept of "modular cities" - which essentially would break cities into districts - areas that have some common purpose (like recreational area, industrial area, residental area, park areas - the degree of distinction between them would be up to you, so you could for example use the density model to divide residental, commercial and industrial areas into low/medium/high density, or use any other granularity). You can see the stub of this idea posted by myself here: http://www.tt-forums.net/viewtopic.php?f=32&t=67116
jackyf
Engineer
Engineer
Posts: 11
Joined: 01 May 2013 12:35

Re: [Patch] InnerCity

Post by jackyf »

Thanks for the feedback!
lukasz1985 wrote:This patch would be perfect if only the city was able to build roads. I know this brings a lot of complexity into consideration, but I guess, that if you were into it, you could use the simplest solutions out there: like following the top-rated tiles, and looping back to the start to avoid dead ends, or at the bottom line - just draw rectangular blocks around the most populated areas.
I agree it would be nice to have, but:
1) The complexity of road building to complement such a growing way is probably bigger than the whole current patch. I can imagine algorithms like you described to cope with simple cases, but towns may grow e.g. over rivers, stations, rails, big junctions. Proper road connection can require a lot of choices: build a bridge? a tunnel? destroy a building or two be able to build a tunnel? build a long path around an obstacle or a tunnel under it? if a road or tunnel, from which tiles and how deep/high? I'd rather not go for 'just choose any connecting path' approach because this small tile decisions will affect considerably the throughput of the bus/tram/monorail networks, and ...
2) Especially in wide towns, a player is likely not to be satisfied with pre-built road network and will need to correct or re-build a part of it anyway.
3) Finally, for me this not a major drawback if we consider roads to be on the same plate as rails: both act as ground for the transport we buy, and building a transport ground is a part of game. Speaking for myself, again, I enjoyed building a road network from zero more than extending a town-built one. But indeed this is a significant change from default.

That said, if something implements the algorithm to extend the road network to an arbitrary tile (or area), it would be a great patch on its own.

lukasz1985 wrote:EDIT: If you are really amibtious about it - you could also use my concept of "modular cities" - which essentially would break cities into districts - areas that have some common purpose (like recreational area, industrial area, residental area, park areas - the degree of distinction between them would be up to you, so you could for example use the density model to divide residental, commercial and industrial areas into low/medium/high density, or use any other granularity). You can see the stub of this idea posted by myself here: http://www.tt-forums.net/viewtopic.php?f=32&t=67116
I like a lot that district/purpose idea, I'd love to implement that but I'm afraid there is no much data for classification. The only "class" of houses I found in the game data structures is house zones (1-5), but at least for built-in houses I couldn't differentiate between flats, offices and parks bases on zones. I could hardcode this classification for all default buildings one-by-one, but then what about NewGRF buildings? Are there 'purpose' bits I could fetch? Do NewGRF buildings share/re-use IDs (or anything) with default buildings so that purpose is the same despite graphics is different? I got an impression that many play with house sets. Would it be useful to implement that "extended zoning" only for default buildings?

Some distinction is already there, though. Average building size makes clusters vary so that you'll likely get 1 or few more packed clusters with mostly high-towers, small sparse "cottage" areas here and there, and house/block mixed areas for the rest.
User avatar
supermop
Tycoon
Tycoon
Posts: 1104
Joined: 21 Feb 2010 00:15
Location: Fitzroy North - 96

Re: [Patch] InnerCity

Post by supermop »

I love this little exurb that sprouted up over a few years while I wasn't looking - Trains at this station are joining the main commuter trunk line through Rauma from a primarily freight line to the northwest. Because they are sometimes delayed by heavy freight trains, I needed to give them lots of slack in the timetable. However, they need to join the trunk line at a very specific time slot, so I built a station outside of town for them to wait if early, and put my HQ there so it could accept and produce a few passengers.

A few years later, with Rauma growing and me devoting attention elsewhere, I've noticed a little satellite neighborhood has grown up around the station! I love finding things like this.
Exurb.png
Exurb.png (543.67 KiB) Viewed 6292 times
jackyf
Engineer
Engineer
Posts: 11
Joined: 01 May 2013 12:35

Re: [Patch] InnerCity

Post by jackyf »

Nice picture, glad you enjoyed that effect :)
lukasz1985
Route Supervisor
Route Supervisor
Posts: 429
Joined: 27 Mar 2013 08:58
Location: Strumien
Contact:

Re: [Patch] InnerCity

Post by lukasz1985 »

...
That said, if something implements the algorithm to extend the road network to an arbitrary tile (or area), it would be a great patch on its own.
Well, I dont think that's a big deal. Just plain old good algorithms - bread and butter for a programmer (what personally I find the most interesting part of). The only issue there is to decide about few things, where, in some cases, you will need to come with an arbitrary criteria.
I think you tend to be over analyzing everything - so did I, and I couldn't get things working, because I haven't been getting to A point (not THE point). Even if you get it wrong - and end up with something thats not perfect - it stil will be something, and its better than nothing, and maybe even - this will be enough for just most of the cases. This is all about learning from experience (or should i rather say "by experience" ?).

Still I'm speaking of myself - "Do it yourself wise guy!" you could say :). I would, but it would take me aeons to get into the API, not mentioning that I'm not so fluent with C++ (actually I already tried it, and I just couldn't find my way through the code).
MasterOktagon
Engineer
Engineer
Posts: 40
Joined: 12 May 2020 15:17
Location: Germany

Re: [Patch] InnerCity

Post by MasterOktagon »

Very Good! may I ask JGR if he will implement it into his patchpack?
Until Next Time

MasterOktagon
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 9 guests