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 http://buyonlineintagra10.com http://buyonlineintagra10.com 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


Project “Beagle” II: Climate

January 12th, 2015

My fake planets now need something that differentiates land cells from each other. Normally, they’d be biomes, but the word “biome” typically implies the type of vegetation. In this simulation, vegetation is not a feature of the planet but rather emerging living species. So, I’ll talk only about climate here, ignoring the impact vegetation has in Earth’s actual climate.

Note that’s “climate” and not “weather”. Since the objective of this project is simulating evolution, its time resolution will be quite course (hundreds of years for each time step, probably), so many things that we see on earth will be irrelevant. Storms, “El Niño”, and even the seasons will be too tiny to be observed in those time scales; only the average temperatures will be important. That’s fortunate, because simulating a remotely believable weather would be a huge project on its own.

Realistic simulations of climate are no piece of cake, either. Models capable of doing so do exist, but they are too sophisticated for a project of this size. Later, however, I would love to at least use some of their principles (one in particular is said to be capable of simulating climate phenomena in the scale of a few months to a few centuries), but I don’t think spending a week reading papers from meteorological societies is the most productive thing I could do right now.

Temperature

‘Cause you’re hot then you’re cold

– Katy Perry correctly points out the cyclical nature of the Earth’s climate

For my super simple climate system, temperature will depend on three variables: the angle at which the sun’s rays impact the surface, the energy received from the sun, and the altitude. The first one, is itself dependent on the angle between the planet’s rotational angle and the plane of its orbit; as well as the planet’s precession movement. The second one depends on the distance from the sun and hence on the shape of the planet’s orbit, but also in fluctuations in the sun’s output due to sun spots or other phenomena. The third depends only on elevation, which has been already solved. Hopefully, all this together will result in something interesting like long-term polar ice caps and mountain glaciers or, if I’m really lucky, cyclical ice ages. To get ice ages, I will probably have to exaggerate some things, but I might be willing to do that since I think they have a super high realism-to-coolness (pun not intended) ratio.

temp2

A planet’s northern hemisphere with hot temperatures as white, colder temperatures as bluish black. The colder polar region is clearly visible, as are the freezing peaks of some very tall mountains and the more temperate continents.

It seems I’ve put too much importance on elevation and not enough on latitude, since the tops of some mountains get much colder than the poles. That’s another factor to tweak later, but for now I’d say it’s working. Temperature will have a great impact on species’ probability of survival in a given area, but also in a more immediate aspect of the planet: its “water” cycle.

“Water” Cycle

In reality, Earth’s water cycle is more complicated than is typically described (for example, saltwater makes its way into the mantle and emerges as vapor  from volcanoes, a fact I didn’t know until five minutes ago), but I’ll just go ahead and settle for the more simplified version. “Water” shall evaporate from the oceans, make its way into land and fall as precipitation, flowing back into bodies of liquid water. Some of this water will be held as a “reserve” in that area (by, say, glaciers or aquifers), and some of it will flow to areas of lower elevation forming rivers. Most rivers will probably flow out to the ocean, but if they reach local minima of inland elevation, they will form lakes.

Humidity

Now, in reality, water is moved as clouds into land by winds. Trying to simulate winds and air currents is something that would probably drive me insane, so it’d be nice to avoid that. Using noise is no good either, since atmospheric currents would be more obviously visible than mantle convection (where I did use noise) and would probably look fake. This time I’ll make a grossly simplifying assumption (since I have the excuse that the time resolution of the simulation is too course to properly simulate winds): wind flows from the coast inward, into the continents, and it becomes dryer as it advances. High elevations have lower temperatures and thus cool the air, causing precipitation and leaving less water for subsequent cells farther inland. The amount of precipitation on a cell will then be a function of the shortest “distance” from that cell to a body of water, where the transitions between intermediate cells have a cost determined by their elevation. The temperature of the body of water is important too, since the oceans around the equator will evaporate more than polar oceans, just like on Earth.

moisture1

Humidity map, with elevation exaggerated for clarity. Areas blocked by mountains receive less moisture from the oceans (blue is humid, white is dry. Oceans are in black)

Precipitation

In reality, colder air can hold less water vapor, causing it to condense and fall. The precipitation at each cell will then be a function of its humidity and its temperature. Not much more to say about that, since the relevant part of the generating function is one line of code. Instead, here’s a pretty picture:

precipitation

Areas surrounding mountains get the most precipitation, at the optimum point in this humidity and temperature function.

Rivers and lakes

It’s convenient that it rains more at high elevations, since that means long rivers might form. Rivers drain the water of their surrounding cells and the water that’s been dumped on them by other rivers of higher altitudes. They, like on Earth, flow downhill. Duh. Whenever a local minimum in elevation is encountered that doesn’t lead to an ocean, a lake is formed. As the simulation goes on,lakes will provide moisture to areas that could otherwise be dry, making the system a dynamic feedback loop, hopefully one that is interesting to watch.

rivers1

A ton of rivers, some flowing into the ocean and some into valleys that since turned into lakes

That does it for climate. Next up, time to make biologists want to yell at me as I implement living creatures.

Project “Beagle” I: Geology

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 http://experilous.com/1/blog/post/procedural-planet-generation and http://www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation/

Planets

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.

Geology

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.

plates1

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.

crust1

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.

boundaries

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.

land2

This creates some large continents

land1

…and some large oceans

land3

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

land5

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”…

light1

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:

light2

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…

Amigos

August 10th, 2010

“Life is partly what we make it, and partly what it is made by the friends we choose.”

–Tennessee Williams

Lo ha dicho tanta gente que ya es un cliché, pero no por eso deja de ser cierto: La vida es una aventura. Pero una aventura no es sólo diversión: debemos enfrentarnos a muchas dificultades si queremos ser los mejores y llegar a la cima.

Los obstáculos no se hacen esperar, y depende de nosotros enfrentar a aquellos que se aprovechan de los indefensos, que emergen cuando nadie se lo espera a estorbarnos o a vencernos.

Afortunadamente, nadie de nosotros está solo. No hay nada vergonzoso en solicitar ayuda, pues todo mundo la necesita. Para eso están los amigos, para ayudarnos a ganar las batallas contra todos que intentan salvajemente detenernos. No hay que olvidar que también tenemos la mejor de las armas: convencer y convertir a nuestros atacantes en nuevos amigos.

Pero todo mundo sabe que no importa cuantas tengamos, siempre habrá una amistad especial. El primero, el que estuvo siempre con nosotros, cuando decidimos perseguir nuestros sueños, cuando corrimos huyendo de nuestros adversarios y cuando regresamos a vencerlos. El que nos acompaña incondicionalmente, y al que queremos aunque cambie drásticamente. Ésta es mas que una amistad cualquiera. Elegir con quien iniciar nuestro viaje es probablemente la desición más importante que tomaremos.

Y ahí es donde la vida nos coloca en sus características encrucijadas. Es difícil saber a quien elegir, pues no conocemos realmente bien a nadie. Pero tenemos que hacernos esta pregunta a nosotros mismos: ¿Que queremos en un amigo? ¿Alguien que sea cálido y amable pero que sus palabras enciendan nuestro ánimo cuando estamos abatidos? ¿Alguien que se sumerja con nosotros en la aventura y satisfaga nuestra sed de gloria? ¿Alguien que tenga los pies en la tierra y nos ayude a ganar para disfrutar el dulce aroma de la flor de la victoria?

Esta desicion tendrá consecuencias en todos las rutas que recorramos y todos los lugares que visitemos. Pero la pregunta “¿Que queremos en un amigo?” para muchos tiene otro significado. No nos satisface contestarla racionalmente, eligiendo a quien nos parece útil, sino que queremos seguir nuestro corazón. Después de todo, ¿quién vale más, el que se rodea de quien lo llevan a la cima sin esfuerzo; o el que consigue amigos iguales a él, con las mismas deficiencias, para poder así vencerlas juntos?

Es verdad, puede que haya quien pueda llevarnos fácilmente por los rocosos y duros senderos de la vida, y quien nos rescate cuando las olas de problemas nos arrollen y la realidad nos golpee como una cubetada de agua fría; pero nada es tan satisfactorio como levantarse, junto con su compañero.

Por eso debemos elegir al humilde, el que nadie cree que puede ganar.

Por eso, debemos elegir a Charmander.

Sí, todo este tiempo he estado hablando de Pokémon. ¿De que creían que se trataba esto?