Home | Rules and Guide | Sign In/Create Account | Write a Post | Reddit | #LD48 | #ludumdare on irc.afternet.org (Info)

Ludum Dare 31 — Coming December 5th-8th 2014! — Join the Mailing List!
  • October Ends: in 30 days, 11 hours, 55 minutes, 5 seconds
  • Ludum Dare 31 begins: in 65 days, 12 hours, 43 minutes, 5 seconds
  • (FYI: Clock might be off) | Ludum Dare 31: Real World Gatherings (Now Open!) | October Challenge 2014!


    Asking for help: how would you simulate a city?

    Posted by
    April 10th, 2013 7:52 am

    I can’t enter LD26 but, rather than complaining and doing nothing about this travesty of priority, I’ve done my own little LD in my evenings.  An hour here and an hour there and, after about 2 days worth, this is how far I got with my city-building game (video):

    WillCity2_1

    Now I must press on and make a proper full game of this!  Its a big project, of course…

    I ask for your help!  How would you simulate a city, at a very deep technical algorithmic level?

    I’ve played around with a “priority flood fill” so that, from each zone of a type, it fills outwards over neighbouring tiles using its score as the priority.  There’s a cost lookup by tile type so residential influence travels further along roads, for example.

    This is very pretty and its neat but is it useful?  Will a large building with a high score ‘drown out’ nearby low-scoring buildings?  Will the influence of a high score building cause it to reach lots of target zones – e.g. residential finding industrial – quickly, meaning it sates the needs of far-off target zones at the cost of nearer but not-yet-high-score zones?   Will it mean a concentration of score?  Will it be intuitive?

    What ways can you think of of actually computing, each sim step, if a zone should increase or decrease score?

    3 Responses to “Asking for help: how would you simulate a city?”

    1. sorceress says:

      I’m guessing your flood fill idea is of this form: Influence(x+1,y) = Influence(x,y) * Fraction

      where Fraction is the proportion of influence carried to the neighbouring tile, possibly a function of TileType(x,y).

      One thing you could do is control how influence generating tiles (buildings) combine their effects, by moving to an energy-diffusion system.

      eg,

      float Decay_Constant = 0.9f; // somewhere between 0 and 1

      iterate a few times {

      for each (x,y) {
      Influence(x,y) *= Decay_Constant; //remove energy from the system
      Influence(x,y) += InfluenceGeneratedBy(x,y)*(1.0f – Decay_Constant); // buildings add energy to the system
      }

      for each (x,y) {
      InfluenceCopy(x,y) = (Influence(x,y) + Influence(x-1,y) + Influence(x+1,y) + Influence(x,y-1) + Influence(x,y+1)) * 0.2f * Fraction; // adiabatic diffusion to neighbouring tiles
      }

      Influence = InfluenceCopy;

      }

    2. Topaz says:

      Not sure if this will help, but I played a game a while back called xlincity, and it was a Debian package which you could download through aptitude. It had a pretty good city simulator and it might give you some ideas.

      http://lincity.sourceforge.net/

    3. mouse click the up coming website

      Asking for help: how would you simulate a city? | Ludum Dare

    Leave a Reply

    You must be logged in to post a comment.


    All posts, images, and comments are owned by their creators.

    [cache: storing page]