Roads are now much less Ridiculous

Well that was both a productive day and an unproductive day, all at the same time.  I started the day with some pretty decent progress.  The previously posted “Day / Night” cycle, tweaked building placements and generation.  Everything was going smoothly…

As mentioned before, I designed an algorithm that followed basically this flow:

  1. Fill the terrain with grass.
  2. Blot dirt patches, and draw roads “roughly” in a grid pattern with some jitter
  3. Run a terrain blending / smoothing step to blend transitional edges and just give some extra character
  4. Place buildings close to the roads.  Intersections carry more weight, and theoretically produce dense groupings
  5. Final terrain decal / debris (and item drops eventually) and a lighting / shadow pass

The strategy looked pretty good on paper, unfortunately it was starting to get expensive trying to detect when buildings would intersect with each other or sections of the road.  I had a mostly working solution when I had the bright idea to rewrite the world generation strategy.

What a setback that was.  If I did this during a real game jam, I’d definitely not be able to finish on time (especially since there still isn’t much in terms of a “playable game” here yet… but it’s very close to some sweet gameplay I swear).

After wrestling with some fairly frustrating bugs (and performance problems… at least I have a loading screen now with a progress bar… and it’s multi-threaded. Woo?).  I’ve now implemented what you see in the following screens:

ScreenShot 1

ScreenShot 2

Other than the wooden buildings? (Yeah I added a new material for building generation to give a little more life to the world and allow for some environmental effects I can’t play with for the stone buildings.

So what are we looking at here?  I’ve changed two parts of my world generation algorithm.  First, the buildings themselves are now not entirely procedurally generated.  They are still placed procedurally and also have some modifications (mirror / rotate / room combinations where doors can line up), but the basic designs are all created manually.  This made things much more aesthetically pleasing than the generated ones, and if there’s not enough variation, it’s dead simple to add a new type to the system and it controls all of the modifications automatically.

The other major change is the building and road interactions.  Now after generating the basic terrain, the algorithm sections the world off into “places of interest”.  For lack of a better phrase, potential landmark sites.  I then select landmark sites, and produce a “village” there.  In the future this can easily be changed to produce other things like: abandoned mines and caves, lakes, railway cars, camps, or basically anything else I can come up with.

After the landmarks have been built, roads are then constructed by using an A* search between landmark sites.  In one of the screen shots you can see this in action where one of the roads didn’t manage to come straight into the town, and instead curves around one of the buildings.  I also have a better system for generating breaks in the roads (as you can see in the first screen shot).

A* was a bit of a pain to implement in this system.  Had I planned on this from the start it might have saved me quite a bit of time.  I did go ahead and generalize it a bit so I can now reuse it for any path tracing I’ll need to do.  I also added the ability to add bounds to the search so I can have NPC’s appropriately give up trying to reach a location that “seems too far away”.  I can then tie this into a stat (like Intelligence for example) that will increase an NPCs search radius for optimal paths.  This will be very useful once I add more object (monster?) avoidance to their AI which could end up causing them to try to path outside of their search bounds.

All in all, a frustrating day with an ultimately exciting conclusion.  If anyone is following along right now, characters are 100% coming tomorrow.  The sprite is already done (for one type anyway) and a ton of the groundwork has been laid.  There are also much nicer looking buildings for them to interact with.  I do still want to add water soon, but I might try to get the characters interacting first before I go there.

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>