My attempt at random city (WIP)

Hello,

I've tried to have a nice random city, but I'm somewhat unsatisfied by the existing tool. I think the cities look too modern, like a suburb where each house is placed along a road, separated from the next one. This is not what I've seen in old, unplanned cities, where everything is much more crammed together.
So, I wondered why wouldn't I try to make my own algorithm to automatically generate a random ancient city? I will try to avoid roads: Large roads will be drawn manually on the map anyway, and minor roads, from my point of view, don't exist: They are just free space between buildings.

I want to share with you my progress on this road. It it leads somewhere, I'll try to see how to integrate the results inside CC3+, but first, let's see if I can get something that suits my taste.

Fist step: Just place buildings randomly, even if they overlap. The goal is just to have the basic elements, the definition of a building, a way to see my results (with zoom & scroll)... So the result is not impressive...

[Image_9398]

Comments

  • GatharGathar Traveler
    edited September 2017
    Second step, this time, we only add a building if it does not overlap another one (I had to implement collision detection to get there). The global algorithm is quite basic (and slow): Try a random building, if it overlaps, forget it and try another one... Once you fail 1000 times in a row, consider your city as finished.

    On the first picture, the algorithm added about 25000 buildings before considering it was done:
    [Image_9396]

    The second picture is a zoomed area of the first one:
    [Image_9397]


    We can see some interesting emerging patterns on these picture, but it clearly does not look like a city at all. I think it might look like people installing tents where they can during a grand meeting of the clans :)
  • Or a typical packed Midievil city, where lanes dead end, etc.
  • DogtagDogtag Moderator, Betatester Traveler
    Very interesting, Gathar. That second image, with the thousands of buildings on it, is impressive, proper city or not.

    Personally, I found tweaking the settings of the Random City Generator can yield some pretty nice results. Even if I don't keep them as generated, I can always delete some streets and copy/paste buildings to make areas more packed or random. Still, I'm curious to see where your experiments take you.

    Thanks for sharing,
    ~Dogtag
  • GatharGathar Traveler
    edited September 2017
    Thank you Jim & Dogtag for your comments

    A third step. This time, I only plant a few buildings totally at random (100 seeds, displayed in blue), then when I create the other ones, I align them with the closest seed. This higher regularity allows to pack 30000 buildings instead of 25000.

    [Image_9405]

    And a zoom:

    [Image_9406]

    While I like this direction better, I think the gaps between the buildings are still too large, I'd like most of them to be in clusters of a few buildings that touch each others, and the the clusters positioned at random. I'm going to think how I can get this result...
  • DogtagDogtag Moderator, Betatester Traveler
  • I like the first city. Really reminds me of Lankhmar. Where over ages the city builds upon itself.
  • jslaytonjslayton Moderator, ProFantasy Mapmaker
    edited September 2017
    http://www.citygen.net/ is a little old, but it might offer some useful inspiration.
  • Thank you jslayton, your link looks quite interesting. I will refrain from reading it just now, as I want to continue a little bit with a fresh mind before looking at what other people did, but I will clearly read it at some point!
  • jslaytonjslayton Moderator, ProFantasy Mapmaker
    I certainly understand the desire to explore your own thoughts before polluting them with the thoughts of others. If you get to the point where you might want o look at what some other folks have done, I have a more in-depth set of links that you might find interesting.
  • 9 days later
  • GatharGathar Traveler
    edited October 2017
    Thank you jslayton, I'll certainly do it when my own ideas will have dried up a little bit!
    Right now, I started to work on this cluster stuff, and I've reached the following result:

    [Image_9464]

    It's been more complex that I thought first, because it's hard to formulate precisely "random, but touching another one". I finally chose this algorithm:
    - Create a random building at a random height
    - Move it horizontally until it touches another building (if there is one at his height, 0 otherwise)
    - Then move it vertically until it touches another one (same special case).

    Next step: Create a city with different clusters (at different angles) and make sure they play nicely with each others. It shouldn't take too long, but I should refrain from starting a new step at 2AM...
  • GatharGathar Traveler
    edited October 2017
    At first, I just put clusters touching one another, but then I decided I whanted to have streets in the city, so I made sure that buildings from one cluster could not be less than 2 meters from buildings from another cluster.

    And here it is:
    [Image_9485]

    And a zoomed-in version:
    [Image_9486]

    I'm quite satisfied of how it turned out.But I'm partial to the subject, so I'd really appreciate to hear comments and suggestions for improvements.

    Do you think it would be worth integrating this algorithm with CC3+? Does anyone have any idea on how to do it? Can a macro be enough? Do I need to write a plug-in? Or maybe I can generate a file in a format that CC3+ can import?
  • MonsenMonsen Administrator 🖼️ 46 images Cartographer
    edited October 2017
    Results look quite interesting.

    As for import to CC3+, there are several options
    - Have your program generate a script file that CC3+ can run. This is the simplest option. A script file is basically just a series of CC3+ commands
    - Write a CC3+ plugin. Orders of magnitudes more complicated than the above options, but allows everything to be easily done from within CC3+.
    - Write a program that communicates with CC3+ through intercom. Basically another way to feed CC3+ commands instead of generating a script file that must be manually run, but also way more complex.
    - Make a program that can actually write the .fcw file format. Then you can simply have your program generate a starting FCW for you, and work it in CC3+.
    - Depending on the complexity of your algorithm, you may be able to implement the entire thing as a macro, but there are limitations for what is reasonable to do in a macro.
  • DogtagDogtag Moderator, Betatester Traveler
    edited October 2017
    Amazing. *doffs cap*

    So, where's Waldo's house?
  • JimPJimP 🖼️ 280 images Cartographer
    edited October 2017
    Dogtag, it's the red house next to the other red houses.

    Sorry Dogtag... my typing goes down hill when I'm tired.
  • jslaytonjslayton Moderator, ProFantasy Mapmaker
    One way to build from your original concept is to modulate general building size by distance from one of a few initial seeds (subject to minimum and maximum size, of course). That way, you'd get the effect of one or more city centers.
  • Gathar, I really like what you are doing here. I really hope that you can make it work in CC3+. I can already picture creating a large fantasy city from this.
  • pvernonpvernon Betatester 🖼️ 34 images Traveler
    Or even more modern cities. Just overlay highways, canals, railroads, etc. add some major points of interest. Done!
  • Gathar, this looks really interesting.

    Would it be possible to add paths that mark larger roads, so the city is generated around the roads? Also, for export to CC3+ it might be a good idea to add an option to mark the outer limits of the city, so it only generates what you really need.
    Importing everything into CC3+ could lead to some performance issues...

    Great job, anyway:D
  • 6 days later
  • Hadrian: I think taking into account a polygon as a limit to place houses should not be too difficult. It might even be interesting to place at least one a cluster aligned with the polygon sides, to make it stand out more. I'll give it a try. Unfortunately, not right now, real life is colliding with this side project...

    jslayton: I might give it a try, but the way I see, it can also be done by the user generating the city not in one go, but once for each kind of neighbourhood, with specific parameters.

    Monsen: Thank you for those ideas. The plugin seems like the more interesting option, I'll see what I can do.

    All the others: Thank you !!
Sign In or Register to comment.