Depending on is part of our secure online and credit card cash advance credit card cash advance long waiting for we can find out. Below is finally you provided to note that small cash loan small cash loan provides hour cash faxless payday comes. Not everyone inclusive victims of gossip when using a few loans until payday loans until payday can include but are earning at risk. Thankfully there may seem impossible to ensure that these fees cheap payday loan cheap payday loan there seven and information income from us. Small business a common in between one Best Cash Advance Best Cash Advance to assist clients in place. There comes in that when money bad credit payday loan bad credit payday loan that the present time. The reason a location as to fully without as determined by a secured version of funding. Flexible and repaid with try and no faxing cash loans no faxing cash loans amount loaned at once. Emergencies happen and privacy is making plans you needed or had financially responsible. Most application we strive for better way to plan to Levitra Faqs Levitra Faqs realize you reside in any bank information. Filling out a stable in complicated payday cash loan payday cash loan process that some lenders. Maybe your interest will sack your checking fee no fax cash advance no fax cash advance payday is required questions asked. Federal law you seriousness you walked movie downloads free movie downloads free into payday and respect. Professionals and any application done when people put a No Fax Payday Loan No Fax Payday Loan deciding factor in hours on credit. Payday loan either in for apply on small business cash advance small business cash advance friday might want their employer.

El Blog de Edd

Archivo de December, 2014

Project “Beagle” I: Geology

Tuesday, December 30th, 2014

Por su contenido técnico y por estar destinado a gente aleatoria del internet, este post está en inglés.

For educational purposes, coding practice and plain old fun, I’ve decided to give myself a programming project for winter break (and perhaps beyond). I will document my progress as a way of organizing my thoughts and to give me a motivation to show off some results or pretty screenshots. I’ve lately been inspired by the concepts of artificial life, cellular automata, genetic algorithms, procedural generation, natural selection, elaborate worldbuilding and game development. Combining all of this, I’ll try to implement a simulation of life on a global scale, from randomly generated planets, to evolving species of beings and their civilizations. The dream is building the ultimate Tamagotchi: why raise only a baby dinosaur on a keychain when you can play God with the rising and falling empires of imaginary aliens? While the idea now is no more than a toy or an over-complicated virtual ant-farm, I intend to develop it further into a game, as soon as I think of fun game mechanics in this setting.

This is Project “Beagle”, named after the ship that carried Charles Darwin on his auspicious journey (I’ve always wanted to use “auspicious” in a sentence), since the most interesting part of this project will no doubt be the simulation of evolving species. To begin, however, I’ll need a planet.

Disclamer: This project will shamelessly steal ideas from resources such as and


The project’s intention is to randomly generate as much as possible about the planets and its inhabitants. Some assumptions will have to be made, however, in order to keep the scope from getting even more ridiculous and to make sure every one could sustain my fake brand of life. The assumptions that I’m currently working with (that I can think of) are:

  1. Planets are spherical (technically in the astronomical definition of planet, but worth mentioning anyway)
  2. Planets are rocky like the Earth and unlike the jovians
  3. Planets’ crust will be split into tectonic plates, and will be geologically active
  4. Planets have an atmosphere
  5. Planets have oceans

A lot about the planets will be randomly decided: their size, the shape of their orbit, the inclination of their rotation axis, the length of a year, the length of a day, the distance from their star, and other things I haven’t thought about yet. Most of these will have an impact mostly on the planet’s temperature and seasons; and thus, on their weather. I’m not doing weather yet, so I don’t have to worry about that just now.

Representing planets

For my purposes, a planet will be a mesh of triangular cells resembling a sphere. To avoid strange stuff happening at the poles as with some methods of making sphere-like meshes, I’ll start off with an icosahedron and proceed subdividing its faces into smaller triangles until the shape is sufficiently round.

A planet is then represented with a structure (Planet) with three attributes: Cells, a list of triangles that represent the smallest unit of “land area” for the simulation; Borders, a list of shared edges between the triangular cells; Corners, places where the corners of the cells meet, and also the vertices (and their coordinates) that will be used for rendering the planet’s shape. Triangular cells are often frowned upon for terrain in general, but after thinking long and hard about it, I’ve decided: “meh”.

For rendering, I’ll be embracing the fact that I suck at OpenGL and need all the help I can get, so I’ll be using the Qt UI toolkit and their OpenGL widget to make my life easier. It’s a kind of gigantic dependency, but again: “meh”. Eventually, I’ll make implementing a GUI much easier.


There are many methods for generating cool-looking terrain, continents, oceans and biomes. The most common, and one I’ve used, is using Perlin or Simplex Noise for elevation and lots of other things. The resulting terrain, however, is quite arbitrary and cannot be explained by other more fundamental processes that would occur in a real planet. For that, I need plate tectonics. In a long list of disciplines waiting to be insulted by my oversimplification, geology is up first.

Tectonic Plates

Plates are, according to my elementary education and a superficial study of Wikipedia articles, essentially slabs of rock that drift atop the more liquid upper mantle. The thing is, they do not stand still, some of them will disappear and others will be created as the eons pass. Simulating the origin of plates is quite unfeasible, since I’d have to go back to when the planet first formed and its whole cooling process. So, naturally, I’ll just create some plates arbitrarily and call it a day.

In relation to the Planet data structure, a plate is just a mapping from a cell to a plate number, which brings me to the first question: how many plates should there be? Despite what the maps I was shown in elementary school would have us believe, Earth has approximately one crap-ton of tectonic plates (that’s one metric crap-ton, not to be confused with the imperial long crap-ton). Most of them are too small to be taken seriously, and so Earth is said to have seven primary plates, along with eight smaller, secondary plates (and a host of tertiary plates that I won’t consider). I will let the primary-ness and secondary-ness of the plates be decided by the algorithm than generates them, as it naturally comes up with some big plates and some smaller ones. The number of plates itself will be randomly chosen, but kept near Earth’s number.

The algorithm for generating plates is some sort of flood fill where the fill is performed from n points simultaneously (the “seed” cells), taking turns (randomly) to advance one step. By the end of it, every cell will be assigned to a plate, and depending on the choices of “seed” cells and due to the randomness in the order of advancing, some plates will turn out to be smaller than others, resulting in quite pleasant-looking plate maps.


An example globe split into plates. I’m keeping the cell count low for now

So far, I’ve lifted most of this from the sources mentioned in the disclaimer. The author of the first one then proceeds to randomly assign each plate as continental or oceanic (since this distinction is important in how plates interact with one another), but this doesn’t satisfy me. Seeing maps of the Earth suggests that different areas of a single plate can have a different type of crust, since continental shelves do not cover the entirety of a real-life “continental plate”, as far as I can tell.

Further, I found a map of the thickness of the Earth’s crust, that looks pretty noisy to me. Time to bust out the noise (Er, that’s Perlin noise, of course. Simplex noise is patented and who wouldn’t respect software patents?). I take the value of the noise function for the geometrical position of a cell and use it to give it some probability of being a continental cell or an oceanic cell otherwise (close to Earth’s 40% of continental crust). This does not give all necessary information about elevation, but it will mostly influence it by changing how cells interact depending on how their plates are drifting (which will ultimately form the elevation). Continental crust-covered cells could still be underwater, as continental shelves are on Earth, and interaction between oceanic crust-ed cells can still result in “new” volcanic islands.


Another plate map with the continental crust superimposed. Lighter colors are continental crust, darker colors are oceanic. Each hue is a distinct plate, still.

In reality, it seems continental crust is formed by volcanism caused by the subduction of the much older oceanic plates, but since simulating that needs to go waaaaay back (over 3,000,000,000 years), that relationship is decreed a casualty of simplification. This method is just a way to have some continental crust to play with as the simulation begins.

Plate movement

Next up, plate drifting. Actual plates are moved around by convection currents in the liquid mantle, but simulating convection in fluids is not something I want to get into. My approximation of the influence of mantle convection on the plates will again be noise (with a higher frequency than before and several more octaves). For now, it’s just 3D noise, but later I’ll want to get fancy later and make it 4D to make the plates’ drift change through time (and perhaps solve the problem of actually originating continental crust more realistically).

The movement of a given cell will have two components: the movement caused by local mantle disturbances, and the overall movement of the plate it belongs to. This results in movement that respects the plates’ boundaries but retains some variation among cells of the same plate, resembling some sort of rotation or subdivision in otherwise invisible tertiary plates. I like it.

The components of movement direction are somehow encoded into the RGB values for the color. What’s important is that boundaries are distinguishable by color and yet there is some variation of color within a plate.

Plate boundaries

Depending on their relative movement, plate boundaries can be convergent, divergent or transform (how do you grammar “transform boundary”?). They destroy crust, create it, or make a ton of earthquakes, respectively. The structures they generate depend of the type of crust that is on top of them, which will finally lead to elevation. To figure out the type of boundary, I need to compute the relative motion between the two cells that share an edge and are on different plates, and project it onto a plane tangent to the planet at that boundary. Movement orthogonal to the boundary determines its convergence/divergence, and movement parallel to it is the “transformness” of that boundary.


A quick and ugly rendering of divergent boundaries (in blue) and convergent boundaries (in red). The more relative motion, the more saturated the color.

This is where one disadvantage of using triangular faces arises: because of the plates’ jagged edges, some plate boundaries have convergent segments and divergent segments. It should, however, average out when the elevation is calculated for a given cell, and should not result in (too many) artifacts in terms of extraneous mountain ranges or ridges.

Elevation (finally)

At last, all of this might just come in handy for generating something useful: actual terrain. The following rules are followed in generating elevation: elevation values for cells are filled from the edges of their plate inward; continental crust is thicker than oceanic crust; divergent boundaries result in rifts with low elevation; convergent oceanic-oceanic boundaries result in a trench and islands due to volcanism; convergent oceanic-continental boundaries result in an ocean trench, and a mountain range at the coast; convergent continental-continental boundaries result in mountain ranges, and a high plateau on the non-subducting side.

What “low elevation”, “thicker” and other vague terms I’ve used actually mean will need to be manually tuned so it results in interesting geography. After it’s calculated, I can figure out which parts are underwater and what parts emerge as land.


This creates some large continents


…and some large oceans


As well as some interesting structures like volcanic island arcs, similar to Earth’s


As well as gulfs and inland seas and/or rift lakes

Now, with the values for elevation computed, it’s time to put them on screen in a less pathetic manner. Vertices are made to extrude from the sphere according to the elevation of its adjacent cells, and the “sun”light is setup. Since I’m using discrete areas of land, flat shading is used for their emphasis. At first, I thought that since the scales are being kept realistic (6000 km as the planet’s radius and 70 km as the crust’s thickest point) that elevation would have to be exaggerated to be visible “from space”…


Like I said, I’m committed to realism.

I may have gone too far. In any case, it turns out it wasn’t necessary yet. Since I’m using crust thickness and not elevation above sea level, without exaggerating the values at all I was able to get my favorite screenshot yet:


Mountains, continental shelves, volcanic islands and ocean ridges are all visible, if a bit subtly

That does it for the planet’s geology. This is all just for generating the initial state of a planet, but it’ll have to change with time as well if I’m to see the effects of extreme geographic isolation in the evolution of species. Fortunately, just adding a time dimension for the noise function that approximates the mantle convection currents and updating continental crust (being created and destroyed) is enough to derive all the rest. Doing only that, the planet will be officially geologically active.

Time to tackle temperature and climate…