Oct 8, 2013

The continuation of the project? Aka: Why so quiet?

It's been quite a few months since my last post. The last 7 months have been pretty busy times from a personal and business perspective. Though I haven't spoken much about my day job in my posts before, I feel it deserves a mention now.

For over three years myself and two other guys ran a software development business specialising in database-driven desktop applications. Running my own business allowed me to take half or whole days off each week to dedicate some quality time to Bulldog.  My take home pay suffered a little as a result, but the bills were getting paid, so it wasn't all that bad.

Not long after my last post in March, through a complicated series of circumstances, our biggest customer suggested we shut down the business and become permanent employees for them. After considering the situation we agreed and set about shutting down the business.

Let me tell you, it's pretty stressful and takes a lot longer than you'd think, especially since we still had to meet our previously agreed development deadlines. We started with them officially on the first of July, and have been pretty busy in our new roles ever since.

A welcome side-effect of the change is a much higher salary and not having to worry about all the busywork you have to do as a small business owner. An unwelcome side-effect of the change is that my work is very full on now and there's no room for work on Bulldog during work hours. Additionally, the work is more draining mentally than before and so when I get home the last thing I feel like doing is firing up Visual Studio again and coding for a few hours.

Despite these setbacks I don't regret my decision at all. My wife and I have another child on the way, so a higher paying job couldn't come at a better time.

So what's happening with Bulldog? Well, the good news is that I've managed some sporadic bursts of coding in the last few months, so the project is not dead. I'm determined to make something of this, so I'm going to continue chipping away where I can.

I've started to write another post which I'll clean up and submit sometime soon hopefully. It details some of the coding I've been doing recently which should take care of one of the most important aspects of the game, terrain generation.

Mar 9, 2013

Development milestone - 2 year mark

Byte Wrangler and the Bulldog project itself are now over 2 years old, hurrah!

So, where is the project? Is it playable yet? No. Why not? Because these things take time. No, that's not a good enough answer. Because I haven't prioritised the right development, and my original estimates for how long it would take were woefully naive. That said, looking back at the codebase from a year ago, the project has advanced a lot further than it seemed a few weeks ago. When you spend so much time so close to the code, you lose sight of all the changes that have built up in the system over the year. And over the last year, a lot of the changes have had a visual impact.

Compare the two screenshots below:

Bulldog Build 1863 - 37,557 lines of code (Jan 2012)

Bulldog Build 11020 - 62,894 lines of code (Feb 2013)

(Note: I added automated build number incrementing in late 2011, so the build number isn't a good indicator of the relative changes in the early days.)

For the statistically minded, the codebase is now 62,894 lines of code, compared to 37,557 a year ago. During the past year, I've done a great deal of refactoring, so large chunks of code have been removed, so the amount of code written is easily more.

A year ago there were no 3d models in the game, aside from the "monolith", which for a long time was the player character's temporary avatar. Now we have a more human shaped temporary avatar, and around 5 in-game 3d models. "Graphics month" failed to live up to its name, and really only introduced a few new graphics, but I did gain a working knowledge of Blender and UV unwrapping, so future modelling will now take much less time.

A year ago there were 13 different items in the game, none of which were usable. The player could walk around, but not interact with anything in the flat, featureless, sandbox world.

Now there are 43 different items in the world, 90% of which fully interact how you'd expect. i.e. you can pick up an empty water bottle and click on a pool of water to fill the bottle. Then you can click the filled bottle on yourself to take a drink.

The most visible graphical change (to me at least), is that I finally managed to get object silhouettes working. This is a feature I've had planned from the very beginning, and is important to the graphical look I want to achieve. I've struggled on and off to make this work, but I eventually had a breakthrough, and while not yet perfect, I'm very happy with the results. I may elaborate more on the specifics in a separate blog post.

Future Development

So, onwards to the future... I've found that it's easier to stay focussed on the tasks for a development snapshot if I give the snapshot a theme. The current snapshot's theme is food & crafting. I've already added 8 new food items to the game and implemented a food spoiling and food poisoning system. The crafting system is in place but needs to be properly tested and the crafting screen needs to be built, as well as adding crafting recipes.

The following build's theme is going to be sounds, shelter and improved terrain generation. Currently there is only one sound in the game, so the sound effects side of things needs a lot of love. I've also been experimenting with some new terrain generation techniques as a proof of concept, and initial work seems really good.

Closing Thoughts

It's easy to become disheartened about progress when your expectations are high and the project is large. I've come to realise that at the outset, my impression of how long it should take was quite naive, mostly due to inexperience. My current estimates suggest it'll be another 2-3 years before its ready for release, which sounds like a long time, but looking at the progress in the last year, I'm optimistic about how good it will look.

Oct 2, 2012

Terrain Features : Pools of Water


For most of August I was working on modifications to the terrain generator. Previously I had to generate the entire world at once, and it had to be square and a power of 2 in size. There also wasn't much leeway for modifying the output data. With the new changes I've made it can generate what I call a "world region", which is a n x m sized region of the world and it has the ability to run feature placement over the output before it gets turned into the final heightmap/tilemap. This also brings it closer to the eventual goal of being able to specify biomes and make use of temperature/moisture maps based on the surrounding sea and mountains.

Feature Placement


The first feature placement algorithm I've been working on is for pools of water. Since fresh water is second only to oxygen in urgency of need for survival, I need to give the player access to water in some fashion otherwise the game will be rather short.

When it comes to terrain generation there's two different approaches you can use. Teleological or ontogenetic. Those sound complicated, but it comes down to asking the question, is the terrain generated as the result of simulating real world processes or is it faked to look like it was?

An example of simulating using real world processes would be to generate a height map using a plate tectonics simulation, then apply many passes of thermal and water erosion algorithms over the result. Next, add water to the world and if sufficient water flows into a local minimum, you have a pool of water.  That's not even the whole story, to be realistic you should also model the permeability of the surrounding rock, the level of the water table, the rainfall for the surrounding area, and so on...

As you can imagine this is pretty complex, as the forces that shape terrain in the real world come about as a result of processes involving physics, chemistry, biology  and geology. The other thing to note is that the terrain all around us was generated over approximately 4.5 billion years, so creating realistic looking terrain through simulation typically takes a lot of iterations even if you take shortcuts.

Faking it


The alternative is to fake the terrain. The general approach is that you use algorithms that have nothing to do with simulating how real terrain is formed. For example, generating some perlin noise, applying a mask to shape the noise to give it the right shape and then smoothing the result using a gaussian blur etc.

I decided to take this approach, since I'm trying to write a game, not a geological simulation of the Earth.  Following the "fake it" approach, my pool placement algorithm looks something like this:


  1. Pick a random spot in the world.
  2. Determine if the area is suitable for a pool of water, ie not too steep. If not, jump back to 1.
  3. Generate a pool shaped terrain depth mask.
  4. Blend the depth mask with the existing heightmap to introduce a depression to the terrain.
  5. Calculate a suitable water level for the pool.
  6. Loop over the lowered terrain adding water where the depth is below the calculated water level.


There are complications will this approach which I won't delve into here at this time as I'm still refining the algorithm. I ran into quite a few problems that I didn't anticipate, such as how to blend the depth mask with the surrounding terrain so that it looks like it's supposed to be there, not just splatted over the top. My initial approach was to smooth the terrain then apply the mask as is, but it tended to produce a flat area that looked out of place.  In the end I came up with a blending approach that uses the distance from the pool as a blending coefficient such that terrain 5 tiles away from the pool uses the local height map and anything closer uses a blend of the two.

Selecting a suitable candidate site was also very important, as some terrain is completely unsuited to forming a pool, for example, if the site has too much of a slope.  Pools placed here tended to look absolutely terrible and often leaked their water out into the rest of the world as the pool edges were too thin.

The part which gave me the most trouble was designating which tiles should be water. The pool placement affects the height map directly, but the game tiles take their height from the surrounding 4 height map values, so I needed a way to determine which tiles are affected by the height map changes and should now be water. I tried a few different "smart" approaches that took advantage of knowledge of the original water mask but found the best solution was actually "dumb", using a flood fill to find the lowest point and then use a recursive fill to process neighbouring height map values. (Thanks to my colleague Ben for suggesting that one). It works like a charm, and has the added benefit of being able to called on the original height map to generate seas or oceans.


Figure 1: The player character enjoys a little swim.

As you can see in the above image, the water renderer is pretty much as basic as you can get. In the future I'd like to add reflections, ripples, specular highlights, waves and a bunch of other effects that help to sell the idea that its actually water, not a flat alpha blended plane. For now though, it will have to do.


Jul 18, 2012

July Progress Report

What's the latest happenings in the world of Bulldog? Well, lately I've been thinking alot about the big picture, such as all the cool features and mechanics I want to have in the end-game. Unfortunately these are likely to years away realistically, but I can't help dreaming.

In a more down to earth sense, I think it's way past time that I start posting screenshots and perhaps even short videos showing how things look. I've been loathe to show anything as I didn't consider it good enough to show, but I've resolved to at least try to put up some screenshots, so here goes:

The player character (placeholder model) standing amongst sand.

Zoomed out view of my test sandbox.

In the past few months I've been continuing work on fleshing out the mechanics of the game. Recently I overhauled my lighting system to handle the dynamic range from full noon sun to middle of the night, but still have appropriate detail visible in either. I also added in the ability to have local sources of light, such as that emitted from torches or explosions. Visibility at night is going to be an important mechanic, so the lighting model is really key to having that be believable.

This month I've been working on the ability to build structures in the game, such as campfires, which has taken alot longer than I expected given how I already had a job queuing system in place. A good deal of the work has been in making the system robust so the player doesn't randomly lose items if he cancels halfway through, or preventing the player from duplicating items through an exploit. I'm also working on a new font that looks a lot better than the previous one I showcased in my article on signed distance fields. I'm excited to see how it turns out in game.