Shortly after returning to work on terrain generation, I realized that I wanted to have a functioning set of gods first, that would have an impact on the world. This, in turn, led me down the path of working on artificial personalities for gods, and the realization that my skill set wasn’t up to snuff for my current goals. So, I’ve been learning functional programming in Scala, have begun to step into machine learning and big data, and will return to this after I have a solid grip on those technologies.
Triumphant Return!
Over the last 5 months, I’ve gotten a new job, moved to a new city, build a new machine (and boy is it a beast), learned a new development methodology (TDD), become adept in a new IDE (IntelliJ IDEA), and have begun migrating the existing codebase to Java 8 and fixing some abstraction issues / assumptions around the size of a player’s screen resolution (which determined the size and position of things on-screen). In a week or two, I’ll have this wrapped up, and continue making progress on terrain generation.
World Parameters
I’ve added a new world generation screen before the one where a player gets to draw their mid-ocean trenches. This screen is used for general world parameters that will have an in-game effect, be it narrative or the generation of terrain and seasons/climate. I gave it six additional preset buttons for users, so they could see the variety of values present within our own solar system, from Mercury, Venus, Earth, Mars, Uranus, or Neptune (the gas giants are hardly good candidates for world parameters to simulate a rocky, habitable planet). I’m now going to begin working on the third screen, where actual tectonic plates are created from the trenches drawn on the second screen. After that will come the fourth screen, where the magic happens and terrain is generated before a player’s eyes.

Numerical Geodynamic Modelling
My first research item, Numerical Geodynamic Modelling by Taras Gerya, was a good 300-page introduction to just how complex what I’m wanting to accomplish will be, if I wanted to achieve truly ‘realistic’ simulation. This put some initial concerns (as well as plans) to rest, while helping me narrow down some general ideas and approaches that I can adapt to my vision.
The big takeaway was how to represent individual chunks of earth, as ‘cells’ in a grid. This grid would be your world map, and since it’s an unmoving frame of reference (an Eulerian Observation window) for a moving world, it is the cells themselves that move (and therefore are Lagrangian observation points). Eulerian and Lagrangian points can be reformulated as one another, as they have an explicit relationship, and at times some ‘conversion’ must be done in order to properly formulate various values that describe the internal state of the cells.
These cells of earth have various properties – pressure, temperature, density, velocity, mass flux, heat flux, stress, strain, strain rate – but not all of which can be calculated without reference to the cells around it. Therefore, some of these values are represented as ‘markers’ in the center of the cell (e.g. gravity) while others must be represented as markers on various faces of the cell (being dependent upon its neighbors), while others still are on the corners of the cell, or the edges inbetween the corners. In a 2D representation, this leads to 8 additional markers representing a single cell (which has one marker in its center), while a 3D model would have 20. This is a staggered grid approach, and is integral to properly modelling the scalars, vectors, and tensors any given cell that represents a moving and changing chunk of the earth.

Taking it further, if we only have one staggered grid, this one grid must represent the finest level of detail our world will have. Properly calculating the values necessary to determine the scalars, vectors, and tensors for all points in the world can take many iterations (sometimes 10, sometimes 100) for all the residual values to level out. It turns out that having multiple grids with coarser and coarser level of detail can assist in this process, and greatly speed up the interpolation of values between cells without sacrificing precision.
By using markers in cells, fully staggered grids, and a multi-grid approach, I am equipped to develope my own approximation of geodynamic processes and plate tectonics, allowing players to create personal worlds with convincing topology that do away with simply taking a slice of a fractal and adding some color to represent water. It’s a more nuanced approach, that takes considerably more computational resources, but the process of world building will feel much more personal. That’s important, because the characters that a person plays are necessarily products of not just the time they live in, but the places they do their living. Worlds are far too interesting to be relegated to fractal generation.
Mid-Ocean Trenches
Drawing mid-ocean trenches is largely complete, as well as rendering the direction of the lava flow on the world map. I’ve begun to dabble in fonts, as well. Next up comes simulating the actual lava flow, and displaying the resulting terrain in time steps (I’ve yet to determine how many years each time step will be, but it is likely to be between 10,000 and 1,000,000).
Lines of Best Fit
I’ve learned how to perform multi-linear regression using Apache Commons Math3, to create polynomial lines of best fit for orders 1 (linear) through 6, in just over one-tenth of a second. This was a critical piece to being able to actually transform drawings of pixels on screen into meaningful entities to use in equations – and it’s very accurate, and very fast.

I used data from the NHANES 3 surveys for age and hand length (in centimeters) for ages 8 through 16. This is part of the data I’ll use to calculate the size of people’s hands, which affect everything from what size gloves they’ll be able to wear, to the measurement of their Thumb Crotch Length (TCL):

It turns out that your TCL is directly related to the ‘ideal’ diameter of anything you grip, affecting your maximum voluntary grip force. In other words, depending on the size of your hand, there’s a definite, mathematical way to figure out just how wide the hilt of that blade needs to be in order for you to most efficiently cleave through your enemies – or just how thick the rope tied to their corpses should be to make it easiest for you to drag them, with a maximum of efficiency and a minimum of discomfort and fatigue.
Tonight was a great success. Next step: calculate R2 (ranges from no fit at 0.0 to perfect fit at 1.0) for these formulas, to see just how well the lines themselves do fit the data, and be able to choose the best one for the best situation. Mid-Ocean Ridges, you’re fast approaching.
Loader, Main Menu Progress
I’ve succeeded in having the loader fetch posts from this WordPress, store them on disk, and display them in the proper order. If posts are missing (even out of order) they are downloaded and re-displayed in the proper order, simply by clicking an update button. Any posts that are found on disk are loaded from there first.

The main menu has a sequence of six shots of a Swiss mountain range and small farmstead with two houses; each shot says on the screen for 15 seconds, before fading out as the next shot fades in, over the same length of time. Players are now able to enter some preliminary information for the creation of a world: the world size, and the axial tilt of the planet itself (which is what drives seasons and much of the weather, since it affects how much solar energy is absorbed/reflected by the surface). Easy presets (such as ‘Earth’) will be offered on this screen in the future and further options are nailed down.

The next screen is where I’ll let user draw (or randomly generate) their mid-ocean trenches, whose regularly flowing lava will be the engines of plate tectonics over tens to hundreds of thousands of years at a time, per ‘tick’. In order to determine the direction part of the angular velocity of such lava flows, each time a user draws a line without lifting up the mouse, a line of best fit will be calculated for those points and stored. At any given point on the line, the lava will flow in eight general directions: tangent, inverse tangent, and two lines halfway in-between each of these. This means if a line is perfectly vertical or horizontal at a point, the lava will flow perfectly into the eight surrounding pixels / points on the map.
Panoramas – An Experiment
I stitched together 12 photographs of Switzerland using various algorithms, with varying results. The first up was Perspective, and was the worst of the lot by a mile – I even left out three of the images on its far-left side, because they didn’t align properly:

The second-to-least promising candidate (though a huge improvement over the first) was the Collage, which has some subtle artifacts when compared side-by-side with the other outputs, despite its clear advantages in perspective, distortion, contrast, and brightness:

The Reposition algorithm introduced the least overall distortion into the photographs, which made its resulting image more cylindrical in shape – not good, since I’d have to throw away a large chunk when I crop out a rectangular shape from it. After all, distortion isn’t necessarily bad, since we want to reverse the distortion introduced by a photographer taking a series of shots from a single vantage point:

The Spherical approach was a clear improvement, but unfortunately it would necessitate cropping out the most interesting feature of the sky: the sun. It’s approaching what I would desire, though – distortion correction within individual images while still attempting to output an image with a top and bottom with minimal overall curvature:

The next-to-best approach was the Automatic algorithm, which tried to guess what I wanted to accomplish, and it was darn close – in fact, in most situations I probably would have chosen this one, but in this situation the upper-third of the image can’t have too much cropping due to the lack of balance when losing much of the sky and sun:

This leaves me with the winner, the Cylindrical approach to creating a panorama, which kept the overall image’s curvature to a minimum while accomplishing an admiral job of stitching together the photographs, and allowing me to preserve a majority of the sky:

Background Art
I’m roughly halfway through the reading and research I want to do before tackling terrain generation with plate tectonics, starting with sea-floor spreading from mid-ocean ridges I let players draw themselves or optionally generate. In the meantime, I’m looking into the best way to generate panoramas from photographs in order to minimize distortion in such a way that I can use photographs that I take or get from stock for suitable background art pieces. It’s a considerable challenge, but thankfully I’m decently skilled in lightroom and photoshop already – transforming them into something that gives the mood and atmosphere I’m wanting to evoke will be much more difficult, as I’ve never done art for a video game before. Even settling on a color palette for various screens and menus will be quite an endeavor. I’ll likely begin looking into good resources for those things around the time I begin to do the coding for tectonics, possibly in a few weeks’ time. I’ve decided to use stock photography from Noah Bradley to help guide my background art – he’s a fantastic artist and a generous contributor to the artistic community. Give his page a visit.
World Creation
Taking a vision and distilling it into something practical and deliverable is a difficult process. World creation is the first one of those for me, and I’m preparing by doing a good deal of reading, and well as talking with people about the pros and cons of various ways to generate maps in 2D. I’ve decided to go a route which starts by taking basic parameters from the player, and generates a world map through several processes:
I will start by taking a world name, an overall world size (in pixels), percent coverage by oceans, and axial tilt of the planetary orbit, and use the parameters as the initial inputs for terrain creation through a simulation of plate tectonics. Sea-Floor spreading and subduction will be central to this process, as well as erosion by precipitation, wind, and heat (and the relative lack of vegetation that certain combinations of those tend to create). Volcanism, earthquakes, hurricanes, tsunamis, and other macro-scale weather events will take place, and play a small part. Every few time-steps (hundreds if not thousands of years) a player will see an updated map of what the world currently looks like, allowing them to stop the process at any point.
It is then that the various Deities I’m bringing into being will become active in the world, and seed it with sentient and non-sentient beings based on their whims and dispositions. Almost all geological processes will cease at this point, and the earth will no longer move like a fluid. This meso-stage will see tribes and civilizations coming into being, and grow in social-political and technological prowess. Before I get to this point, I have a fair amount of reading and coding to do. I’m starting with the following:
Benedetti & Minto – Tectonic Plate Simulation on Procedural Terrain
Erlangen – Interactive Terrain Rendering: Towards Realism with Procedural Models and Graphics Hardware
Dollins – Modeling for the Plausible Emulation of Large Worlds
Doran & Parberry – COntrolled Procedural Terrain Generation Using Software Agents
Viitanen – Physically Based Terrain Generation: Procedural Heightmap Generation Using Plate Tectonics
Taras Gerya – Introduction to Numerical Geodynamic Modeling
Additionally, in order to keep learning about the past of these role-playing games we all know and love so much, I’m reading “Playing at the World,” by Jon Peterson, and to keep up to snuff on the technological development of the human race, I’m going through Volume 1 (of 7) of Oxford University’s History of Technology.