[patch] coastal cities

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
db48x
Engineer
Engineer
Posts: 16
Joined: 14 Feb 2009 07:11

[patch] coastal cities

Post by db48x »

I discovered openttd a few days ago, and after playing a while (I can almost make a correct 4-way junction) I figure I'd jump in and see if I can help improve it. Since none of the games I've played so far have had much scope for ship traffic I figured I would start there.

To that end this patch makes the terrain generator add a few more towns to the coastline. I implemented it in the simplest possible way. When generating towns, any time it randomly generates a position that wouldn't be suitable because it's underwater I simply have it search nearby for the nearest land tile. Of course, that tile itself will never be suitable, since it'll be a sloped tile, so I then search near it for a nice flat spot further inland.

The results are moderately successful. On a small map it might give you one extra town, on a 2k×2k map with a high town density I generally get about 150-200 extra. On the other hand, since they all pretty much right next to the coast they tend to be pretty small, with populations in the 20-200 range. I found I had to add a check to make sure the population of the towns is never zero, because occasionally it would find some tiny ledge on the side of a mountain with room for exactly one road square to build on. Obviously that could have happened in any game without this patch, but it would have been very unlikely.

Enjoy, and let me know what you think.
Attachments
coastal.diff
coastal cities more likely; diff against revision r15476
(3.08 KiB) Downloaded 135 times
LordAzamath
Tycoon
Tycoon
Posts: 1656
Joined: 08 Jun 2007 08:00

Re: [patch] coastal cities

Post by LordAzamath »

The idea is good.. Any screenies of minimap?
PS: And I stopped the propaganda to support Dave Worley since he got a nice new red hat now.[/color]
I know I have a BBCode error in my signature but I really cba to fix it.
User avatar
NukeBuster
Traffic Manager
Traffic Manager
Posts: 222
Joined: 04 Jan 2006 18:16
Location: Alphen aan den Rijn, The Netherlands
Contact:

Re: [patch] coastal cities

Post by NukeBuster »

This sounds like an interesting patch, I usually regenerate the map about 10 times before getting a map with good coastal cities.
NukeBuster

Transport Empire: The Transport Empire Linux effort
Join the Transport Empire IRC channel: [url]irc://irc.oftc.net/transportempire[/url] !

OpenTTD patch(es): Password at join
db48x
Engineer
Engineer
Posts: 16
Joined: 14 Feb 2009 07:11

Re: [patch] coastal cities

Post by db48x »

Sure, I can do a screenshot.
Attachments
Unnamed, 1st Jan 1950.png
(261.91 KiB) Downloaded 410 times
db48x
Engineer
Engineer
Posts: 16
Joined: 14 Feb 2009 07:11

Re: [patch] coastal cities

Post by db48x »

Here's an updated version. Apparently it was pretty late when I was doing this, because I made a silly logic error that was producing suboptimal results.

Also, here's a screenshot showing some debug info that illustrates how it works.
Unnamed, 1st Jan 1950#2.png
(226.4 KiB) Downloaded 258 times
Attachments
coastal-2.diff
(3.4 KiB) Downloaded 116 times
db48x
Engineer
Engineer
Posts: 16
Joined: 14 Feb 2009 07:11

Re: [patch] coastal cities

Post by db48x »

the patch in the bug in slightly newer. just a minor tweak http://bugs.openttd.org/task/2635
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: [patch] coastal cities

Post by Yexo »

db48x wrote:the patch in the bug in slightly newer. just a minor tweak http://bugs.openttd.org/task/2635
It would be nice if you actually uploaded the patch there :p
db48x
Engineer
Engineer
Posts: 16
Joined: 14 Feb 2009 07:11

Re: [patch] coastal cities

Post by db48x »

Thanks Yexo. I'm pretty sure I told it to upload when I filed the bug, but I dunno…
el koeno
Route Supervisor
Route Supervisor
Posts: 454
Joined: 24 Sep 2004 15:47

Re: [patch] coastal cities

Post by el koeno »

Welcome to OTTD. Nice work: useful, unobtrusive, but I haven't tested it yet so I can't really say. I'd like to make a suggestion: Cities spawning on mountains annoy me. Little villages are okay, but if I want to connect the bigger cities with proper rail links, it's quite annoying if there's one that's hardly reachable with a rail link that isn't insanely steep. I mean: if a town is so hard to reach, would it ever grow into a large city?
db48x
Engineer
Engineer
Posts: 16
Joined: 14 Feb 2009 07:11

Re: [patch] coastal cities

Post by db48x »

el koeno wrote:Welcome to OTTD. Nice work: useful, unobtrusive, but I haven't tested it yet so I can't really say. I'd like to make a suggestion: Cities spawning on mountains annoy me. Little villages are okay, but if I want to connect the bigger cities with proper rail links, it's quite annoying if there's one that's hardly reachable with a rail link that isn't insanely steep. I mean: if a town is so hard to reach, would it ever grow into a large city?
Thanks

I agree with you here, although this patch doesn't really affect it either way. I suppose we could make a separate patch to try and address it. The easiest thing to do would be to reset the city flag to false if the town couldn't grow enough to make it worth while.
db48x
Engineer
Engineer
Posts: 16
Joined: 14 Feb 2009 07:11

Re: [patch] coastal cities

Post by db48x »

The patch has been updated to make a few improvements. I'd like to encourage you guys to test it out - you the game better than I, so you will be more likely to notice if anything is amiss. Thanks.
Attachments
coastal-6.diff
(9.98 KiB) Downloaded 131 times
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 13 guests