Human and nature dynamics (HANDY): Modeling inequality and use of resources in the collapse or sustainability of societies

Leave a comment



HANDY is a 4-variable thoughtexperiment model for interaction of humans and nature.

The focus is on predicting long-term behavior rather than short-term forecasting.

Carrying Capacity is developed as a practical measure for forecasting collapses.

A sustainable steady state is shown to be possible in different types of societies.

But over-exploitation of either Labor or Nature results in a societal collapse.


There are widespread concerns that current trends in resource-use are unsustainable, but possibilities of overshoot/collapse remain controversial. Collapses have occurred frequently in history, often followed by centuries of economic, intellectual, and population decline. Many different natural and social phenomena have been invoked to explain specific collapses, but a general explanation remains elusive.

In this paper, we build a human population dynamics model by adding accumulated wealth and economic inequality to a predator–prey model of humans and nature. The model structure, and simulated scenarios that offer significant implications, are explained. Four equations describe the evolution of Elites, Commoners, Nature, and Wealth. The model shows Economic Stratification or Ecological Strain can independently lead to collapse, in agreement with the historical record.

The measure “Carrying Capacity” is developed and its estimation is shown to be a practical means for early detection of a collapse. Mechanisms leading to two types of collapses are discussed. The new dynamics of this model can also reproduce the irreversible collapses found in history. Collapse can be avoided, and population can reach a steady state at maximum carrying capacity if the rate of depletion of nature is reduced to a sustainable level and if resources are distributed equitably.

Graphical abstract


  • Human–nature dynamics;
  • Societal collapse;
  • Carrying capacity;
  • Overshoot vs. sustainability;
  • Economic inequality;
  • Ecological strain

1. Introduction

There are widespread concerns that current trends in population and resource-use are unsustainable, but the possibilities of an overshoot and collapse remain unclear and controversial. How real is the possibility of a societal collapse? Can complex, advanced civilizations really collapse? It is common to portray human history as a relentless and inevitable trend toward greater levels of social complexity, political organization, and economic specialization, with the development of more complex and capable technologies supporting ever-growing population, all sustained by the mobilization of ever-increasing quantities of material, energy, and information. Yet this is not inevitable. In fact, cases where this seemingly near-universal, long-term trend has been severely disrupted by a precipitous collapse – often lasting centuries – have been quite common. A brief review of some examples of collapses suggests that the process of rise-and-collapse is actually a recurrent cycle found throughout history, making it important to establish a general explanation of this process (Chase-Dunn and Hall, 1997, Goldstein, 1988, Meadows et al., 1972, Modelski, 1987, Tainter, 1988, Turchin and Nefedov, 2009 and Yoffee and Cowgill, 1988).

The Roman Empire’s dramatic collapse (followed by many centuries of population decline, economic deterioration, intellectual regression, and the disappearance of literacy) is well known, but it was not the first rise-and-collapse cycle in Europe. Prior to the rise of Classical Greco-Roman civilization, both the Minoan and Mycenaean Civilizations had each risen, reached very advanced levels of civilization, and then collapsed virtually completely (Morris, 2006 and Redman, 1999). The history of Mesopotamia – the very cradle of civilization, agriculture, complex society, and urban life – presents a series of rise-and-declines including the Sumerians, the Akkadian, Assyrian, Babylonian, Achaemenid, Seleucid, Parthian, Sassanid, Umayyad, and Abbasid Empires (Redman et al., 2004 and Yoffee, 1979). In neighboring Egypt, this cycle also appeared repeatedly. In both Anatolia and in the Indus Valley, the very large and long-lasting Hittite and Harrapan civilizations both collapsed so completely that their very existence was unknown until modern archeology rediscovered them. Similar cycles of rise and collapse occurred repeatedly in India, most notably with the Mauryan and the Gupta Empires (Edwards et al., 1971, Edwards et al., 1973, Jansen et al., 1991,Kenoyer, 1998 and Thapar, 2004). Southeast Asia similarly experienced “multiple and overlapping histories of collapse and regeneration” over 15 centuries, culminating in the Khmer Empire based in Angkor, which itself was depopulated and swallowed by the forest during the 15th Century (Stark, 2006). Chinese history is, very much like Egypt’s, full of repeated cycles of rises and collapses, with each of the Zhou, Han, Tang, and Song Empires followed by a very serious collapse of political authority and socioeconomic progress (Chu and Lee, 1994, Lee, 1931 and Needham and Wang, 1956).

Collapses are not restricted to the “Old World”. The collapse of Maya Civilization is well known and evokes widespread fascination, both because of the advanced nature of Mayan society and because of the depth of the collapse (Demerest et al., 2004 and Webster, 2002). As Diamond (2005) puts it, it is difficult to ignore “the disappearance of between 90 and 99% of the Maya population after A.D. 800 …and the disappearance of kings, Long Count calendars, and other complex political and cultural institutions.” In the nearby central highlands of Mexico, a number of powerful states also rose to high levels of power and prosperity and then rapidly collapsed, Teotihuacan (the sixth largest city in the world in the 7th C) and Monte Alban being just the largest of these to experience dramatic collapse, with their populations declining to about 20–25% of their peak within just a few generations (Tainter, 1988).

We know of many other collapses including Mississippian Cultures such as Cahokia, South West US cultures such as the Pueblo and Hohokam, Andean civilizations such as Tiwanaku, Sub-Saharan civilizations such as Great Zimbabwe, and many collapses across the Pacific Islands, such as Easter Island. It is also likely other collapses have also occurred in societies that were not at a sufficient level of complexity to produce written records or archeological evidence. Indeed, a recent study (Shennan et al., 2013) of the Neolithic period in Europe has shown that “in contrast to the steady population growth usually assumed, the introduction of agriculture into Europe was followed by a boom-and-bust pattern in the density of regional populations”. Furthermore “most regions show more than one boom–bust pattern”, and in most regions, population declines “of the order of the 30–60%” can be found. The authors also argue that, rather than climate change or diseases, the timing and evidence point to endogenous causes for these collapses in 19 out of 23 cases studied, suggesting the possibility of “rapid population growth driven by farming to unsustainable levels”. Moreover, through wavelet analysis of the archeological data, S. Downey [personal communication] has shown that the average length of such boom-and-bust cycles is about 300–500 years.

In summary, despite the common impression that societal collapse is rare, or even largely fictional, “the picture that emerges is of a process recurrent in history, and global in its distribution” (Tainter, 1988). See also Yoffee and Cowgill (1988), Goldstein (1988), Ibn Khaldun (1958), Kondratieff (1984), and Parsons (1991). As Turchin and Nefedov (2009) contend, there is a great deal of support for “the hypothesis that secular cycles — demographic–social–political oscillations of a very long period (centuries long) are the rule, rather than an exception in the large agrarian states and empires.”

This brings up the question of whether modern civilization is similarly susceptible. It may seem reasonable to believe that modern civilization, armed with its greater technological capacity, scientific knowledge, and energy resources, will be able to survive and endure whatever crises historical societies succumbed to. But the brief overview of collapses demonstrates not only the ubiquity of the phenomenon, but also the extent to which advanced, complex, and powerful societies are susceptible to collapse. The fall of the Roman Empire, and the equally (if not more) advanced Han, Mauryan, and Gupta Empires, as well as so many advanced Mesopotamian Empires, are all testimony to the fact that advanced, sophisticated, complex, and creative civilizations can be both fragile and impermanent.

A large number of explanations have been proposed for each specific case of collapse, including one or more of the following: volcanoes, earthquakes, droughts, floods, changes in the courses of rivers, soil degradation (erosion, exhaustion, salinization, etc.), deforestation, climate change, tribal migrations, foreign invasions, changes in technology (such as the introduction of ironworking), changes in the methods or weapons of warfare (such as the introduction of horse cavalry, armored infantry, or long swords), changes in trade patterns, depletion of particular mineral resources (e.g., silver mines), cultural decline and social decadence, popular uprisings, and civil wars. However, these explanations are specific to each particular case of collapse rather than general. Moreover, even for the specific case where the explanation applies, the society in question usually had already experienced the phenomenon identified as the cause without collapsing. For example, the Minoan society had repeatedly experienced earthquakes that destroyed palaces, and they simply rebuilt them more splendidly than before. Indeed, many societies experience droughts, floods, volcanoes, soil erosion, and deforestation with no major social disruption (Tainter, 1988).

The same applies to migrations, invasions, and civil wars. The Roman, Han, Assyrian, and Mauryan Empires were, for centuries, completely militarily hegemonic, successfully defeating the neighboring “barbarian” peoples who eventually did overrun them. So external military pressure alone hardly constitutes an explanation for their collapses. With both natural disasters and external threats, identifying a specific cause compels one to ask, “yes, but why did this particular instance of this factor produce the collapse?” Other processes must be involved, and, in fact, the political, economic, ecological, and technological conditions under which civilizations have collapsed have varied widely. Individual collapses may have involved an array of specific factors, with particular triggers, but a general explanation remains elusive. Individual explanations may seem appropriate in their particular case, but the very universal nature of the phenomenon implies a mechanism that is not specific to a particular time period of human history, nor a particular culture, technology, or natural disaster (Tainter, 1988, Turchin, 2003 and Yoffee and Cowgill, 1988).

In this paper we attempt to model collapse mathematically in a more general way. We propose a simple model, not intended to describe actual individual cases, but rather to provide a general framework that allows carrying out “thought experiments” for the phenomenon of collapse and to test changes that would avoid it. This model (called HANDY, for Human and Nature DYnamics) advances beyond existing biological dynamic population models by simultaneously modeling two separate important features which seem to appear across so many societies that have collapsed: (1) the stretching of resources due to the strain placed on the ecological carrying capacity (Abel, 1980,Catton, 1980, Kammen, 1994, Ladurie, 1987, Ponting, 1991, Postan, 1966, Redman, 1999, Redman et al., 2004, Wood, 1998 and Wright, 2004), and (2) the economic stratification of society into Elites and Masses (or “Commoners”) (Brenner, 1985,Parsons, 1991, Turchin, 2005, Turchin, 2006, Turchin and Nefedov, 2009, Diamond, 2005 and Goldstone, 1991; Ibn Khaldun, 1958). In many of these historical cases, we have direct evidence of Ecological Strain and Economic Stratification playing a central role in the character or in the process of the collapse (Culbert, 1973, Diamond, 2005,Goldstone, 1991, Lentz, 2000 and Mitchell, 1990). For these empirical reasons, and the theoretical ones explained in Section 3, our model incorporates both of these two features. Although similar to the Brander and Taylor (1998) model (hereafter referred to as “BT”) in that HANDY is based on the classical predator–prey model, the inclusion of two societal classes introduces a much richer set of dynamical solutions, including cycles of societal and ecological collapse, as well as the possibility of smoothly reaching equilibrium (the ecological carrying capacity). We use Carrying Capacity in its biological definition: the population level that the resources of a particular environment can sustain over the long term (Catton, 1980, Cohen, 1995 and Daly and Farley, 2003). In this paper, we call these environment resources “Nature”.

The paper is organized as follows: Section 2 gives a brief review of the predator–prey model; Section 3 includes the mathematical description of HANDY; Section 4 covers a theoretical analysis of the model equilibrium and possible solutions; Section 5 presents examples of scenarios within three distinct types of societies; Section 6 gives an overall discussion of the scenarios from 5 and 7 offers a short summary of the paper and a discussion of future work.

2. Predator–Prey Model

The predator–prey model, the original inspiration behind HANDY, was derived independently by two mathematicians, Alfred Lotka and Vitto Volterra, in the early 20th century (Lotka, 1925 and Volterra, 1926). This model describes the dynamics of competition between two species, say, wolves and rabbits. The governing system of equations is


In the above system, x represents the predator (wolf) population; y represents the prey (rabbit) population; a determines the predator’s birth rate, i.e., the faster growth of wolf population due to availability of rabbits; b is the predator’s death rate; c is the prey’s birth rate; d determines the predation rate, i.e., the rate at which rabbits are hunted by wolves.

Rather than reaching a stable equilibrium, the predator and prey populations show periodic, out-of-phase variations about the equilibrium values


Note consistency of the units on the left and right hand sides of Eqs. (1) and (2). A typical solution of the predator–prey system can be seen in Fig. 1.

A typical solution of the predator–prey system obtained by running the system ...
Fig. 1.

A typical solution of the predator–prey system obtained by running the system with the following parameter values and initial conditions: a = 3.0 × 10− 5 (rabbits·years)− 1; b = 2.0 × 10− 2 years− 1, c = 3.0 × 10− 2 years− 1, d = 2.0 × 10− 4 (wolves·years)− 1; x(0) = 1.0 × 10+ 2 wolves; and y(0) = 1.0 × 10+ 3 rabbits. Predator population is measured in units of wolves, Prey population is measured in units of rabbits, and Time is measured in units of years.


As indicated above, Human And Nature DYnamics (HANDY) was originally built based on the predator–prey model. We can think of the human population as the “predator”, while nature (the natural resources of the surrounding environment) can be taken as the “prey”, depleted by humans. In animal models, carrying capacity is an upper ceiling on long-term population. When the population surpasses the carrying capacity, mechanisms such as starvation or migration bring the population back down. However, in the context of human societies, the population does not necessarily begin to decline upon passing the threshold of carrying capacity, because, unlike animals, humans can accumulate large surpluses (i.e., wealth) and then draw down those resources when production can no longer meet the needs of consumption. This introduces a different kind of delay that allows for much more complex dynamics, fundamentally altering the behavior and output of the model. Thus, our model adds the element of accumulated surplus not required in animal models, but which we feel is necessary for human models. We call this accumulated surplus “wealth”.

Empirically, however, this accumulated surplus is not evenly distributed throughout society, but rather has been controlled by an elite. The mass of the population, while producing the wealth, is only allocated a small portion of it by elites, usually at or just above subsistence levels. Based on this, and on the historical cases discussed in the introduction, we separated the population into “Elites” and “Commoners”, and introduced a variable for accumulated wealth. For an analysis of this two-class structure of modern society, see Drăgulescu and Yakovenko (2001) and Banerjee and Yakovenko (2010). This adds a different dimension of predation whereby Elites “prey” on the production of wealth by Commoners. As a result, HANDY consists of four prediction equations: two for the two classes of population, Elites and Commoners, denoted by xE and xC, respectively; one for the natural resources or Nature, y; and one for the accumulated Wealth, w, referred to hereafter as “Wealth”. This minimal set of four equations seems to capture essential features of the human–nature interaction and is capable of producing major potential scenarios of collapse or transition to steady state.

A similar model of population and renewable resource dynamics based on the predator–prey model was developed in the pioneering work of Brander and Taylor (1998)demonstrating that reasonable parameter values can produce cyclical “feast and famine” patterns of population and resources. Their model showed that a system with a slow-growing resource base will exhibit overshooting and collapse, whereas a more rapidly growing resource base will produce an adjustment of population and resources toward equilibrium values. They then applied this model to the historical case of Easter Island, finding that the model provides a plausible explanation of the population dynamics known about Easter Island from the archeological and scientific record. They thus argue that the Polynesian cases where population did collapse were due to smaller maximum resource bases (which they call “carrying capacity”) that grew more slowly, whereas those cases which did not experience such a collapse were due to having a larger resource base (i.e., a larger carrying capacity). They then speculate that their model might be consistent with other historical cases of collapse, such as the ancient Mesopotamian and Maya civilizations or modern Rwanda.

However, the BT approach only models Population and Nature and does not include a central component of these historical cases: economic stratification and the accumulation of wealth. Thus, despite clear evidence for a stratified class structure in Easter Island’s history prior to the collapse (as well as for Mesopotamia, the ancient Maya, and modern Rwanda), the BT model does not include class stratification as a factor. In their model, society produces and consumes as a single homogeneous unit. We feel that a historically realistic modeling of the evolution of human–nature dynamics in these stratified complex societies cannot be achieved without including this class stratification in the model. Brander and Taylor recognize that their model is simple, and that application to more complex scenarios may require further development of the structure of the model. We have found that including economic stratification, in the form of the introduction of Elites and Commoners, as well as accumulated Wealth, results in a much richer variety of solutions, which may have a wider application across different types of societies. HANDY’s structure also allows for “irreversible” collapses, without the need to introduce an explicit critical depensation mechanism into the model as other models need to do. Thus while the Brander–Taylor model has only two equations, HANDY has four equations to predict the evolution of the rich and poor populations (Elites and Commoners), Nature, and accumulated Wealth (we examine other differences in Section 6.4 of the paper) The HANDY equations are given by:


It is to be noted that αC, αE, CC, and CE are all functions of w, xC, and xE. See Eqs. (4) and (6) and Fig. 2a and b.

Per capita Consumption rates and Death rates for Elites and Commoners as a ...
Fig. 2.

Per capita Consumption rates and Death rates for Elites and Commoners as a function of Wealth. Famine starts when View the MathML source. Therefore, Commoners start experiencing famine when View the MathML source, while Elites do not experience famine until View the MathML source. This delay is due to Elites’ unequal access to Wealth.

3.1. Model Description

The total population is divided between the two variables, xC and xE, representing the population of commoners and of elites. The population grows through a birth rate β and decreases through a death rate α. β is assumed to be constant for both Elites and Commoners but α depends on Wealth as explained below.

In reality, natural resources exist in three forms: nonrenewable stocks (fossil fuels, mineral deposits, etc.), regenerating stocks (forests, soils, animal herds, wild fish stocks, game animals, aquifers, etc.), and renewable flows (wind, solar radiation, precipitation, rivers, etc.). Future generations of the model will disaggregate these forms. We have adopted a single formulation intended to represent an amalgamation of the three forms, allowing for a clear understanding of the role that natural resources play in collapse or sustainability of human societies.

Thus, the equation for Nature includes a regeneration term, γy(λ − y), and a depletion term, − δxCy. The regeneration term has been written in the form of a logistic equation, with a regeneration factor, γ, exponential regrowth for low values of y, and saturation when y approaches λ, Nature’s capacity — maximum size of Nature in absence of depletion. As a result, the maximum rate of regeneration takes place when y = λ / 2. Production is understood according to the standard Ecological Economics formulations as involving both inputs from, and outputs to, Nature (i.e., depletion of natural sources and pollution of natural sinks) ( Daly, 1996 and Daly and Farley, 2003). This first generation of HANDY models the depletion side of the equation as if it includes the reduction in Nature due to pollution.

The depletion term includes a rate of depletion per worker, δ, and is proportional to both Nature and the number of workers. However, the economic activity of Elites is modeled to represent executive, management, and supervisory functions, but not engagement in the direct extraction of resources, which is done by Commoners. Thus, only Commoners produce.

It is frequently claimed that technological change can reduce resource depletion and therefore increase carrying capacity. However, the effects of technological change on resource use are not unidirectional. Technological change can raise the efficiency of resource use, but it also tends to raise both per capita resource consumption and the scale of resource extraction, so that, absent policy effects, the increases in consumption often compensate for the increased efficiency of resource use. These are associated with the phenomena referred to as the Jevons Paradox, and the “Rebound Effect” (Greening et al., 2000, Polimeni et al., 2008 and Ruth, 2009). For example, an increase in vehicle fuel efficiency tends to enable increased per capita vehicle miles driven, heavier cars, and higher average speeds, which then negate the gains from the increased fuel-efficiency. In addition, technological advances can enable greater resource extraction and throughput, which then appears as increases in the productivity of other factors of production. As Daly points out, much of the increase in productivity in both agriculture and industry in the last two centuries has actually come from increased (rather than decreased) resource throughput ( Daly, 1991). A decline in the price of a resource is usually thought to reflect an increase in the abundance of that resource, but in fact, it often reflects that the resource is simply being extracted more rapidly. Rather than extend carrying capacity, this reduces it. Over the long-term, per capita resource-use has tended to rise over time despite dramatic technological advances in resource efficiency. Thus, the sign and magnitude of the effect of technological change on resource use varies and the overall effect is difficult to predict. Therefore, in this generation of HANDY, we assume that the effects of these trends cancel each other out. The model will be developed further to allow the rates of these technology-induced trends to be adjusted in either direction.

Finally, there is an equation for accumulated Wealth, which increases with production,δxCy, and decreases with the consumption of the Elites and the Commoners, CC and CE, respectively. The consumption of the Commoners (as long as there is enough wealth to pay them) is sxC, a subsistence salary per capita, s, multiplied by the working population. The Elites pay themselves a salary κ times larger, so that the consumption of the Elites isκsxE. However, when the wealth becomes too small to pay for this consumption, i.e., when w < wth, the payment is reduced and eventually stopped, and famine takes place, with a much higher rate of death. κ is meant to represent here the factors that determine the division of the output of the total production of society between elites and masses, such as the balance of class power between elites and masses, and the capacity of each group to organize and pursue their economic interests. We recognize the inherent limitations, in this initial generation of our model, of holding that balance (κ) constant in each scenario, but we expect to develop κ further in later generations of HANDY so that it can be endogenously determined by other factors in the model.

CC and CE, the consumption rates for the Commoner and the Elite respectively, are given by the following equations:


Wealth threshold, wth, is a threshold value for wealth below which famine starts. It depends on the “minimum required consumption per capita”, ρ:


Even when Commoners start experiencing famine, i.e., when w ≤ wth, the Elites continue consuming unequally as indicated by the factor κ in the second term on the right hand side of Eq. (5). A graphical representation of the consumption rates are given in Fig. 2a.

The death rates for the Commoner and the Elite, αC and αE, are functions of consumption rates:


The death rates vary between a normal (healthy) value, αm, observed when there is enough food for subsistence, and a maximum (famine) value, αM that prevails when the accumulated wealth has been used up and the population starves. There are a variety of mechanisms which can reduce population when it exceeds carrying capacity, including everything from emigration, increased disease susceptibility, and outright starvation to breakdowns in social order and increased social violence, such as banditry, riots, rebellions, revolutions, and wars. These mechanisms are described in detail in Turchin (2003) but the net effect of all of them is a reduction in population, and that is what the dynamics of our model is meant to represent when we say “population decline” or “famine”. Note also that an increase in the death rates (α) is equivalent to an equal decrease in the birth rates (β). The death rates αC and αE   can be expressed in terms of View the MathML source, a graphical representation of which is given Fig. 2b.

3.2. A Note on Units and Dimensions

There are three dimensions for quantities in HANDY:


Population (either Commoner or Elite), in units of people.


Nature/Wealth, in units of “ecoDollars”.


Time, in units of years.

The structure of the model requires Nature and Wealth to be measured with the same units, therefore we created the unit eco-dollar. Other parameters and functions in the model carry units that are compatible with the abovementioned dimensions following Eq.(3). For example, Carrying Capacity, χ, and the Maximum Carrying Capacity, χM, defined in Section 4.1, are both expressed in units of people.

4. Equilibrium Values and Carrying Capacity

We can use the model to find a sustainable equilibrium and maximum carrying capacity in different types of societies. In order for population to reach an equilibrium, we must have αm ≤ βE ≤ βC ≤ αM. We define a dimensionless parameter, η:


Since we assume αm ≤ βC ≤ αM, η will always be bounded by 0 ≤ η ≤ 1.

4.1. Equilibrium when xE = 0 (No Elites): Egalitarian Society

Assuming xE ≡ 0, we can find the equilibrium values of the system (subscript “e” denotes the equilibrium values):


We define χ, the Carrying Capacity for the population, to be equal to xC,e in Eq. (8), i.e., the equilibrium value of the population in the absence of Elites:


Carrying Capacity can be maximized if Nature’s regeneration rate is maximal, i.e., if View the MathML source. This requires δ to be set equal to a value δ* that can result in a steady state with the maximum (sustainable) Population, which in this paper we call the “optimal” value of δ. From the second equation in Eq. (8), it can be seen that δ* is given by:


The Maximum Carrying Capacity, χM, is thus given by:


4.2. Equilibrium when xE ≥ 0 and κ = 1 (No Inequality): Equitable Society

If we set κ ≡ 1 and βE ≡ βC ≡ β, we can reach an equilibrium state for which xE ≥ 0. This case models an equitable society of “Workers” and “Non-Workers”. We need a dimensionless free parameter φ that sets the initial ratio of the Non-Workers to Workers:


The equilibrium values of the system can then be expressed as follows:


The total population xe = xC,e + xE,e can still be maximized by choosing δ appropriately:


This δ** is larger than the optimal depletion factor given by Eq. (10). The difference arises because Workers have to produce more than they need just for themselves in order to support Non-Workers. For this choice of δ, total population is given by:


As can be seen from Eq. (15), maximum total population in equilibrium is independent ofφ and conforms to the maximum carrying capacity given above by Eq. (11).

4.3. Equilibrium when xE ≥ 0 and κ > 1: Unequal Society

It is possible to attain equilibrium in an unequal society if we can satisfy the following condition:


(The general condition αm ≤ βE ≤ βC ≤ αM must hold in all cases for an equilibrium to be feasible.)

The equilibrium values in this general case can be expressed as follows:


The free parameter, ψ, is the equilibrium ratio xE,e/xC,e, apparent from the second equation in Eq. (17). As opposed to φ, ψ cannot be easily related to the initial conditions; rather, it can be determined from the result of a simulation.

Again, the total population xe = xC,e + xE,e can be maximized by choosing δ appropriately:


This required depletion rate δ*** can be even larger than the optimal δ given by Eq. (14)depending upon the values of κ and ψ. In the presence of inequality, the maximum total population is no longer independent of κ and ψ and is smaller than the maximum carrying capacity given by Eqs.  (11) and (15):


5. Scenarios

We discuss three sets of scenarios:


Egalitarian society (No-Elites): Scenarios in which xE = 0.


Equitable society (with Workers and Non-Workers): Scenarios in which xE ≥ 0 butκ ≡ 1.


Unequal society (with Elites and Commoners): Scenarios in which xE ≥ 0 and κ > 1.

For all of these scenarios, we start the model with the typical parameter values and initial conditions given in Table 1, unless otherwise stated. As indicated above, the values of κand xE(0) determine the type of the society. Within each type of society, we obtain different scenarios by varying the depletion factor, δ.

Table 1.Description of parameters and state variables used in HANDY. κ, δ, and xE are varied to study various scenarios in three different types of societies. xE = 0 defines an Egalitarian society with no Elites. κ = 1 defines an Equitable society with Workers and Non-Workers, represented by xC and xE in this case, respectively. xE ≥ 0 and κ > 1 define an unequal society with Elites and Commoners (xE and xC). As a reference, all other variables and functions in HANDY are also listed above. Subscript e denotesequilibrium value everywhere in this paper.

Parameter symbol Parameter name Typical value(s)
αm Normal (minimum) death rate 1.0 × 10− 2
αM Famine (maximum) death rate 7.0 × 10− 2
βC Commoner birth rate 3.0 × 10− 2
βE Elite birth rate 3.0 × 10− 2
s Subsistence salary per capita 5.0 × 10− 4
ρ Threshold wealth per capita 5.0 × 10− 3
γ Regeneration rate of nature 1.0 × 10− 2
λ Nature carrying capacity 1.0 × 10+ 2
κ Inequality factor 1, 10, 100
δ Depletion (production) factor None
Variable symbol Variable name Typical initial value(s)
xC Commoner population 1.0 × 10+ 2
xE Elite population 0, 1, 25
y Nature λ
w Accumulated wealth 0
(a). List of parameters in HANDY. κ and δ take different values for different scenarios.

(b). List of state variables in HANDY. xE(0) takes different values for different scenarios.

In this section, we will show that HANDY is capable of modeling three distinct types of societies by changing κ and xE(0). A sustainable equilibrium can be found for each society by controlling δ. An appropriate choice of δ can make this equilibrium optimal, i.e., with maximum total population. Increasing δ above its optimal value makes the approach toward equilibrium oscillatory. Such an equilibrium is suboptimal, and the Carrying Capacity is below its maximum value, χM. It is also possible to reach a suboptimal equilibrium (a less than maximum, but sustainable population) by making δ lower than its optimal value. However, in the latter case, the approach toward equilibrium would be a soft landing rather than oscillatory. When δ is increased even further, the society goes into cycles of prosperity and collapse. Increasing δ beyond a certain point will result in an irreversible Type-N (full) collapse, examples of which are presented in 5.1.4,5.2.4 and 5.3.2. We give a full categorization of collapses in the next two paragraphs.

Running the model in different scenarios produces two kinds of collapses, either due to scarcity of labor (following an inequalityinduced famine) or due to scarcity of Nature (depletion of natural resources). We categorize the former case as a Type-L (Disappearance of Labor) Collapse and the latter as a Type-N collapse (Exhaustion of Nature). In a Type-L collapse, growth of the Elite Population strains availability of resources for the Commoners. This causes decline of the Commoner Population (which does the labor), and consequently, decline of Wealth. Finally, Elite Population plummets since its source of subsistence, i.e., Wealth, has vanished. See Fig. 6a for an example of a Type-L collapse. This could represent a historical case such as the disappearance of the Mayan civilization in the Yucatan. Note that this type of collapse can only happen in an unequal society, because the major cause behind it is inequality.

A Type-N collapse, on the other hand, starts with an exhaustion of Nature, followed by a decline of Wealth that in turn, causes a fall of the Commoners and then the Elites. Depending on the depletion rate, Type-N collapses can be “reversible” or “irreversible”. After a reversible collapse, regrowth of nature can trigger another cycle of prosperity, examples of which can be seen in Figs. 3c and 4c. This could represent historical cases such as the Greek and Roman collapses.

Experiment results for the Egalitarian society.
Fig. 3.

Experiment results for the Egalitarian society.

Experiment results for the Equitable society.
Fig. 4.

Experiment results for the Equitable society.

When depletion is pushed beyond a certain limit, Nature fully collapses and the whole system completely collapses after that. This is why we call an irreversible Type-N collapse a “full” collapse. Examples of such collapses can be seen in Figs. 3d, 4d, and 6b. This could represent a historical case such as the exhaustion of Nature on Easter Island. Type-N collapses can arise because of excessive depletion only ( Figs. 3d and 4d), or both excessive depletion and inequality ( Fig. 6b).

It is important to understand the inter-relation of the depletion factor, δ, and the Carrying Capacity, χ. The further δ is taken away from its optimal value, the further χ moves down from its maximum value, χM. An equilibrium can be reached if and only if χ is not too far away from χM, which means δ cannot be too far away from its optimal value, given by Eqs.  (10), (14) and (18) in the three types of societies under consideration. Note that in all of the scenario outputs presented below (for the three types of societies under consideration), Carrying Capacity (χ) and the Maximum Carrying Capacity (χM) are calculated from their defining Eqs.  (9) and (11), respectively.

Important note about the units of the vertical axis of all the subsequent graphs: Populations, xC and xE, and the Carrying Capacity, χ, are all normalized to the Maximum Carrying Capacity, χM. Nature and Wealth are both shown in units of Nature’s capacity, λ. The top scale of the vertical axis of the graph pertains to Population(s) and Carrying Capacity; the middle scale pertains to Nature, which (normally) stays bounded by 1λ; and the bottom scale is for Wealth.

Note: All the simulations below use the Euler integration method with a time-step of 1 year and single precision.

5.1. Egalitarian Society (No-Elites): xE = 0

In the four following scenarios, κ does not play any role since we set xE ≡ 0. We start the depletion rate from δ = δ, the optimal equilibrium value that maximizes the Carrying Capacity, and increase it slowly to get additional scenarios. The horizontal red line in the graphs for the four scenarios of this section represents the zero population of Elites.

5.1.1. Egalitarian Society: Soft Landing to Equilibrium

For the scenario in Fig. 3a, δ = δ = 6.67 × 10− 6. Therefore, the carrying capacity, χ, is at its maximum level, χM. Notice that Nature also settles to ye = λ / 2, which is the value that results in the maximum regeneration rate. This maximal regeneration can in turn support a maximum sustainable depletion and population.

If we set δ < δ*, we still see a soft landing to the carrying capacity, χ. However, χ would be at a lower level than χM because a lower-than-optimal δ does not correspond to the maximum regeneration of nature, which is a necessity if we want to have the maximum sustainable population. The advantage of a lower-than-optimal δ is a higher equilibrium level (compared to λ / 2) for Nature.

Choosing a depletion rate, δ, that is too small to produce enough to feed the population would result in a collapse, and thus make any equilibrium impossible even though Nature stays at its maximum capacity. Of course, this would not occur in the real world as the urge for survival guarantees humans extract their basic needs from nature.

5.1.2. Egalitarian Society: Oscillatory Approach to Equilibrium

For the scenario in Fig. 3b, δ is increased to δ = 2.5δ = 1.67 × 10− 5. As can be seen fromFig. 3b, the carrying capacity, χ, is lower than its maximum value, χM. Population initially overshoots the carrying capacity, then oscillates, and eventually converges to it since the amount of overshoot is not too large, just about the order of χ. Note that at the time the (total) population overshoots the Carrying Capacity, the Wealth also reaches a maximum and starts to decline.

5.1.3. Egalitarian Society: Cycles of Prosperity, Overshoot, Collapse, and Revival

For the scenario in Fig. 3c, δ is increased to δ = 4δ = 2.67 × 10− 5. As can be seen, Population, Nature and Wealth all collapse to a very small value. However, after depletion becomes small due to very low number of workers, Nature gets a chance to grow back close to its capacity, λ. The regrowth of Nature kicks off another cycle of prosperity which ends with another collapse. Simulation results show that these cycles, ending in Type-N collapses (i.e., those that start due to scarcity of Nature), repeat themselves indefinitely. Therefore, such cycles represent “reversible” Type-N collapses. This reversibility is possible as long as δ stays within a “safe” neighborhood of δ*.

5.1.4. Egalitarian Society: Irreversible Type-N Collapse (Full Collapse)

For the scenario in Fig. 3d, δ is increased further to δ = 5.5δ = 3.67E − 5. The overshoot is so large that it forces Population, Nature and Wealth into a full collapse, after which there is no recovery. This is a generic type of collapse that can happen for any type of society due to over-depletion. See 5.2.4 and 5.3.2 for examples of irreversible Type-N collapses in equitable and unequal societies, respectively. We include further discussion of these two types of collapses in Section 6.

We observe that the accumulated Wealth delays a decline of the population even after Nature has declined well below its capacity, λ. Therefore, population keeps growing and depleting Nature until Nature is fully exhausted. At that instance, i.e., when y = 0, Wealth cannot grow any further; indeed, it starts plummeting, causing a sharp fall of the population level, and eventually its full, irreversible collapse.

5.2. Equitable Society (with Workers and Non-Workers): κ = 1

We take the parameter values and the initial conditions to be the same as in Table 1, except that this time we set xE(0) = 25 (φ = 0.25) and κ = 1. We start with the optimal depletion per capita δ = δ**, which will sustain the maximum population (see Eq. (14)), and will gradually increase it in order to get the additional scenarios in this subsection. Notice that in these cases, xC describes the Working Population, while xE describes the Non-Working Population. Everybody consumes at the same level, since we set κ = 1, i.e., we assume there is no inequality in consumption level for Workers and Non-Workers.

5.2.1. Equitable Society: Soft Landing to Optimal Equilibrium

For the scenario in Fig. 4a, δ = δ∗∗ = 8.33 × 10− 6. Notice that this is larger than the optimal value in the absence of Non-Workers δ = 6.67 × 10− 6 even though all the other parameters are identical to those in Section 5.1.1. This difference arises because xE ≠ 0, which in turn forces the Workers to produce extra in order to support the Non-Workers. Now, χ < χM because δ = δ∗∗ ≠ δ. However, by setting δ = δ**, the optimal value of δ in the presence of Non-Workers, the total population, xC + xE still reaches the maximum Carrying Capacity, χM, the same as in Section 5.1. See Eq.  (15) and Section 4.2 for a mathematical description.

Similar comments as in Section 5.1.1 apply here when we choose a lower-than-optimalδ.

5.2.2. Equitable Society: Oscillatory Approach to Equilibrium

For the scenario in Fig. 4b, δ = 2.64δ∗∗ = 2.20 × 10− 5. The total population is equal to the actual Carrying Capacity (smaller than the maximum Carrying Capacity).

5.2.3. Equitable Society: Cycles of Prosperity, Overshoot, Collapse, and Revival

For the scenario in Fig. 4c, δ = 3.46δ∗∗ = 3.00 × 10− 5. The result is analogous to Fig. 3c which corresponds to Section 5.1.3. As before, the time at which the total population overshoots the actual Carrying Capacity is indicated by the fact that Wealth starts to decrease. After each cycle of prosperity, there is a partial, reversible Type-N collapse.

5.2.4. Equitable Society: Full Collapse

For the scenario in Fig. 4d, δ = 5δ∗∗ = 4.33 × 10− 5. Once again, we can see how an irreversible Type-N (full) collapse of Population, Nature, and Wealth can occur due to over-depletion of natural resources as a result of high depletion per capita.

5.2.5. Equitable Society: Preventing a Full Collapse by Decreasing Average Depletion per Capita

The case in Fig. 5 is similar to the previous case (see Section 5.2.4 and Fig. 4d), except that we raised the ratio of Non-Workers to Workers, φ, from 0.25 to 6. This corresponds to changing xE(0) from 25 to 600, while keeping xC(0) = 100. By increasing the ratio of non-workers to workers, a sustainable equilibrium can be reached due to lower average depletion per capita — an equivalent δ if everyone contributed equally to labor. This could also be interpreted as modeling a reduction in the average workload per worker.

The full collapse that happened in the previous scenario, Fig. 4d, can be ...
Fig. 5.

The full collapse that happened in the previous scenario, Fig. 4d, can be prevented by reducing the average depletion per capita. This can be achieved by either increasing the ratio of the Non-Working to Working population (high δ, high φ) or decreasing the average workload per worker, i.e., decreasing total work hours per week (low δ, low φ).

5.3. Unequal Society (with Elites and Commoners): xE ≥ 0 and κ > 1

In our examples of an unequal society, the Elites (per capita) consume κ < 10 to 100 times more than the Commoners. Their population, plotted in red, is multiplied by κ to represent their equivalent impact because of their higher consumption. That is why we use the label “Equivalent Elites” on the graphs in this Section 5.3.

In the first two cases, we discuss two distinct, but generic types of collapse in an unequal society. In these two scenarios, κ = 100. Then we will show possibility of reaching an equilibrium by reducing κ to 10 and adjusting the birth rates βE and βC independently. These two κ = 10 scenarios show that in order to reach a sustainable equilibrium in an unequal society, it is necessary to have policies that limit inequality and ensure birth rates remain below critical levels.

5.3.1. Unequal Society: Type-L Collapse (Labor Disappears, Nature Recovers)

This scenario, presented in Fig. 6a, is precisely the same as the equilibrium without Elites case presented in Section 5.1.1 (Fig. 3a) except that here we set xE(0) = 1.0 × 10− 3. This is indeed a very small initial seed of Elites. The two scenarios look pretty much the same up until about t = 500 years after the starting time of the simulation. The Elite population starts growing significantly only after t = 500, hence depleting the Wealth and causing the system to collapse. Under this scenario, the system collapses due to worker scarcity even though natural resources are still abundant, but because the depletion rate is optimal, it takes more than 400 years after the Wealth reaches a maximum for the society to collapse. In this example, Commoners die out first and Elites disappear later. This scenario shows that in a society that is otherwise sustainable, the highly unequal consumption of elites will still cause a collapse.

Experiment results for the Unequal society.
Fig. 6.

Experiment results for the Unequal society.

This scenario is an example of a Type-L collapse in which both Population and Wealth collapse but Nature recovers (to its maximum capacity, λ, in the absence of depletion). Scarcity of workers is the initial cause of a Type-L collapse, as opposed to scarcity of Nature for a Type-N collapse.

5.3.2. Unequal Society: Irreversible Type-N Collapse (Full Collapse)

The typical scenario in Fig. 6b for a full collapse is the result of running the model with the parameter values and initial conditions given by Table 1. Examples of irreversible Type-N (full) collapses in the egalitarian and equitable societies are presented in Section 5.1.4(Fig. 3d) and Section 5.2.4 (Fig. 4d).

We set a small initial seed of xE(0) = 0.20, κ = 100, and a large depletion δ = 1.0 × 10− 4, so that both the depletion δ = 15δ* and the inequality coefficient κ = 100 are very large. This combination results in a full collapse of the system with no recovery. The Wealth starts declining as soon as the Commoner’s population goes beyond its carrying capacity, and then the full collapse takes only about 250 additional years. The declining Wealth causes the fall of the Commoner’s population (workers) with a time lag. The fast reduction in the number of workers combined with scarcity of natural resources causes the Wealth to decline even faster than before. As a result, the Elites – who could initially survive the famine due to their unequal access to consumable goods (κ = 100) – eventually also die of hunger. Note that because both depletion and inequality are large, the collapse takes place faster and at a much lower level of population than in the previous case (see Section 5.3.1, Fig. 5.3.1) with a depletion rate of δ = δ*.

5.3.3. Unequal Society: Soft Landing to Optimal Equilibrium

The following parameter values and initial values can produce the current scenario (the rest are exactly the same as in Table 1):


The value for δ used in this scenario is δ*** given by Eq.  (18). It must be remembered thatψ = 0.65 is not a parameter that we can choose. However, it can be read from the result of the simulation since it is the equilibrium ratio of the Elite to Commoner population. See the second equation in Eq. (17). On the other hand, View the MathML source is determined by the death and birth rates as well as the inequality coefficient. These parameters are chosen in order to satisfy Eq. (16), the necessary condition for attaining an equilibrium in an unequal society.

The same comments as in Section 5.1.1 hold here if we choose a lower-than-optimal δ.

5.3.4. Unequal Society: Oscillatory Approach to Equilibrium

The parameter values and initial conditions in the scenario presented in Fig. 6d are exactly the same as the previous scenario, presented in Fig. 6c, except for δ. It is increased to 1.3 × 10− 5, almost 2δ***. This results in a much lower Carrying Capacity compared to 5.3.3, as can be seen from a comparison of Fig. 6c and d. Therefore, the total final population in the present scenario is much less than the total final population in the previous scenario, 5.3.3 ( Fig. 6c) ( Table 2).

Table 2.As a reference, all other variables and functions in HANDY are listed in this table. Subscript e denotesequilibrium value everywhere in this paper.

Variable symbol Variable name Defining equation
wth Threshold wealth Eq. (5)
ω Normalized wealth w / wth
CC Commoner consumption Eq. (4) (Fig. 2a)
CE Elite consumption Eq. (4) (Fig. 2a)
αC Commoner death rate Eq. (6) (Fig. 2b)
αE Elite death rate Eq. (6) (Fig. 2b)
η η Eq. (7)
χ Carrying Capacity (CC) Eq. (9)
δ* Egalitarian optimal δ Eq. (10)
χM Maximum Carrying Capacity (Max CC) Eq. (11)
φ Ratio of non-workers to workers (Equitable) Eq. (12)
δ** Equitable optimal δ Eq. (14)
ψ Elite to commoner equilibrium ratio (Unequal) xE,e / xC,e
δ*** Unequal optimal δ Eq. (18)

6. Discussion of Results

We conducted a series of experiments with the HANDY model, considering first an egalitarian society without Elites (xE = 0), next an equitable society (κ = 1) where Non-Workers and Workers are equally paid, and finally an unequal society whose Elites consume κ times more than the Commoners. The model was also used to find a sustainable equilibrium value and the maximum carrying capacity within each of these three types of societies.

6.1. Unequal Society

The scenarios most closely reflecting the reality of our world today are found in the third group of experiments (see the scenarios for an unequal society in Section 5.3), where we introduced economic stratification. Under such conditions, we find that collapse is difficult to avoid, which helps to explain why economic stratification is one of the elements recurrently found in past collapsed societies. Importantly, in the first of these unequal society scenarios, 5.3.1, the solution appears to be on a sustainable path for quite a long time, but even using an optimal depletion rate (δ*) and starting with a very small number of Elites, the Elites eventually consume too much, resulting in a famine among Commoners that eventually causes the collapse of society. It is important to note that this Type-L collapse is due to an inequalityinduced famine that causes a loss of workers,rather than a collapse of Nature. Despite appearing initially to be the same as the sustainable optimal solution obtained in the absence of Elites, economic stratification changes the final result: Elites’ consumption keeps growing until the society collapses. The Mayan collapse – in which population never recovered even though nature didrecover – is an example of a Type-L collapse, whereas the collapses in the Easter Island and the Fertile Crescent – where nature was depleted – are examples of a Type-N collapse.

In scenario 5.3.2, with a larger depletion rate, the decline of the Commoners occurs faster, while the Elites are still thriving, but eventually the Commoners collapse completely, followed by the Elites. It is important to note that in both of these scenarios, the Elites – due to their wealth – do not suffer the detrimental effects of the environmental collapse until much later than the Commoners. This buffer of wealth allows Elites to continue “business as usual” despite the impending catastrophe. It is likely that this is an important mechanism that would help explain how historical collapses were allowed to occur by elites who appear to be oblivious to the catastrophic trajectory (most clearly apparent in the Roman and Mayan cases). This buffer effect is further reinforced by the long, apparently sustainable trajectory prior to the beginning of the collapse. While some members of society might raise the alarm that the system is moving towards an impending collapse and therefore advocate structural changes to society in order to avoid it, Elites and their supporters, who opposed making these changes, could point to the long sustainable trajectory “so far” in support of doing nothing.

The final two scenarios in this set of experiments, 5.3.3 and 5.3.4, are designed to indicate the kinds of policies needed to avoid this catastrophic outcome. They show that, in the context of economic stratification, inequality must be greatly reduced and population growth must be maintained below critical levels in order to avoid a societal collapse (Daly, 2008).

6.2. Egalitarian Society

In order to further understand what conditions are needed to avoid collapse, our first set of experiments model a society without economic stratification and start with parameter values that make it possible to reach a maximum carrying capacity (scenario 5.1.1). The results show that in the absence of Elites, if the depletion per capita is kept at the optimal level of δ*, the population grows smoothly and asymptotes the level of the maximum carrying capacity. This produces a soft-landing to equilibrium at the maximum sustainable population and production levels.

Increasing the depletion factor slightly (scenario 5.1.2) causes the system to oscillate, but still reach a sustainable equilibrium, although, importantly, at a lower carrying capacity. Population overshoots its carrying capacity, but since the overshoot is not by too much – of the order of the carrying capacity – the population experiences smaller collapses that can cause it to oscillate and eventually converge to a sustainable equilibrium. Thus, while social disruption and deaths would occur, a total collapse is avoided.

A further increase in the depletion factor (scenario 5.1.3) makes the system experience oscillatory periods of growth, very large overshoots and devastating collapses that almost wipe out society, but the eventual recovery of Nature allows for the cycle to be repeated.

Increasing the depletion factor even further (scenario 5.1.4) results in a complete collapse of the system. This shows that depletion alone, if large enough, can result in a collapse — even in the absence of economic stratification.

6.3. Equitable Society (with Workers and Non-Workers)

As the second set of experiments (presented in Section 5.2) show, HANDY allows us to model a diverse range of societal arrangements. In this set of experiments, choosingxE ≥ 0 and κ = 1 has allowed us to model a situation that can be described as having Workers and Non-Workers with the same level of consumption, i.e., with no economic stratification. The Non-Workers in these scenarios could represent a range of societal roles from students, retirees, and disabled people, to intellectuals, managers, and other non-productive sectors. In this case, the Workers have to deplete enough of Nature to support both the Non-Workers and themselves.

The first scenario, 5.2.1, shows that even with a population of Non-Workers, the total population can still reach a sustainable equilibrium without a collapse. In scenario 5.2.2, we find that increasing the depletion factor induces a series of overshoots and small collapses where population eventually converges to a lower sustainable equilibrium. Like in an egalitarian society, scenario 5.2.3 shows us that increasing the depletion parameter further results in cycles of large overshooting, major collapses, and then eventual recovery of Nature. Scenario 5.2.4 shows us that increasing depletion per capita further can produce an irreversible Type-N collapse.

Finally, scenario 5.2.5, which is a replication of the scenario in 5.2.4 with a much higher ratio of Non-Workers to Workers, shows that a collapse in an equitable society could be avoided by reducing the average depletion per capita. We note that this scenario could also represent a situation where, rather than having paid Non-Workers, the workload per capita is reduced, with the whole population working “fewer days a week”. Such a “work-sharing” policy has been successfully implemented in Germany over the past few years for reducing unemployment (Baker and Hasset, 2012 and Hasset, 2009). Moreover,Knight et al. (2013) show, through a panel analysis of data for 29 high-income OECD countries from 1970 to 2010, that reducing work hours can contribute to sustainability by reducing ecological strain. This conclusion agrees with our comparison of the two scenarios, 5.2.5 and 5.2.4, presented above.

6.4. HANDY and Brander–Taylor Model

As previously mentioned, a similar use of the predator–prey approach was applied in the pioneering work of Brander and Taylor (1998) (BT) to study the historical rise and fall of the Easter Island population. In comparison to their model, with just two equations for Population and Nature, the introduction of Elites and Commoners, and accumulated Wealth, results in a greater variety and broader spectrum of potential solutions. Moreover, the collapse scenario presented in BT is somewhat different from the ones presented above. As a matter of fact, the collapse scenario presented in Fig. 3 of Brander and Taylor (1998) seems to be more of an oscillatory approach to equilibrium, similar to the one shown in our Fig. 3b, and not a collapse in the sense that we define in this paper. Furthermore, the carrying capacity, in the sense we define in this paper, is also different from what BT (1998) call carrying capacity. Indeed, their carrying capacity (K) is our Nature’s capacity, λ, which is the maximum size Nature can reach, whereas Carrying Capacity in HANDY is the population level that can be supported by a given level of natural resources. Furthermore, BT’s carrying capacity is a constant, whereas Carrying Capacity in HANDY adjusts according to the level of depletion of Nature.

While sharing certain similarities with the Brander and Taylor model, our more complex model structure and the use of different assumptions, allows our model to apply to multiple types of societies with varying socioeconomic structures. Thus, unlike works that tend to study further implications of the two-dimensional model of BT (Anderies, 2000), the model we have developed introduces a more complex set of possible feedbacks and nonlinear dynamics, and a greater spectrum of potential outcomes. This allows HANDY to model a different and wider set of thought experiments.

An important feature of HANDY that distinguishes it from predator–prey, BT, and other similar models (Anderies, 1998, Dalton et al., 2005, Erickson and Gowdy, 2000 and Reuveny and Decker, 2000) is its native capability for producing irreversible collapses due to the structure for accumulation of wealth. Our approach also differs from models like D’Alessandro (2007) that can produce irreversible collapses but only through explicit introduction of a critical depensation mechanism into the model. The dynamics produced by HANDY offer the possibility of irreversible collapses without having to introduce such an additional mechanism into the model. See Section 5.1.4 for an explanation of irreversible collapses in HANDY.1

7. Summary

Collapses of even advanced civilizations have occurred many times in the past five thousand years, and they were frequently followed by centuries of population and cultural decline and economic regression. Although many different causes have been offered to explain individual collapses, it is still necessary to develop a more general explanation. In this paper we attempt to build a simple mathematical model to explore the essential dynamics of interaction between population and natural resources. It allows for the two features that seem to appear across societies that have collapsed: the stretching of resources due to strain placed on the ecological carrying capacity, and the division of society into Elites (rich) and Commoners (poor).

The Human And Nature DYnamical model (HANDY) was inspired by the predator and prey model, with the human population acting as the predator and nature being the prey. When small, Nature grows exponentially with a regeneration coefficient γ, but it saturates at a maximum value λ. As a result, the maximum regeneration of nature takes place atλ / 2, not at the saturation level λ. The Commoners produce wealth at a per capita depletion rate δ, and the depletion is also proportional to the amount of nature available. This production is saved as accumulated wealth, which is used by the Elites to pay the Commoners a subsistence salary, s, and pay themselves κs, where κ is the inequality coefficient. The populations of Elites and Commoners grow with a birth rate β and die with a death rate α which remains at a healthy low level when there is enough accumulated food (wealth). However, when the population increases and the wealth declines, the death rate increases up to a famine level, leading to population decline.

We show how the carrying capacity – the population that can be indefinitely supported by a given environment (Catton, 1980) – can be defined within HANDY, as the population whose total consumption is at a level that equals what nature can regenerate. Since the regrowth of Nature is maximum when y = λ / 2, we can find the optimal level of depletion (production) per capita, δ* in an egalitarian society where xE ≡ 0, δ∗∗(≥ δ) in an equitable society where κ ≡ 1, and δ*** in an unequal society where xE ≥ 0 and κ > 1.

In sum, the results of our experiments, discussed in Section 6, indicate that either one of the two features apparent in historical societal collapses – over-exploitation of natural resources and strong economic stratification – can independently result in a complete collapse. Given economic stratification, collapse is very difficult to avoid and requires major policy changes, including major reductions in inequality and population growth rates. Even in the absence of economic stratification, collapse can still occur if depletion per capita is too high. However, collapse can be avoided and population can reach equilibrium if the per capita rate of depletion of nature is reduced to a sustainable level, and if resources are distributed in a reasonably equitable fashion.

In the upcoming generations of HANDY, we plan to develop several extensions including: (1) disaggregation of Nature into nonrenewable stocks, regenerating stocks, and renewable flows, as well as the introduction of an investment mechanism in accessibility of natural resources, in order to study the effects of investment in technology on resource choice and production efficiency; (2) making inequality (κ) endogenous to the model structure; (3) introduction of “policies” that can modify parameters such as depletion, the coefficient of inequality, and the birth rate; and, (4) introduction of multiple coupled regions to represent countries with different policies, trade of carrying capacity, and resource wars.

Those interested in obtaining the model code can contact the authors.


We are grateful to Profs. Matthias Ruth, Victor Yakovenko, Herman Daly, Takemasa Miyoshi, Jim Carton, Fernando Miralles-Wilhelm, and Ning Zeng, and Drs. Robert Cahalan and Steve Penny for many useful discussions. Study of the “Equitable Society” scenarios (i.e., with Workers and Non-Workers), the scenario presented in Section 5.2.5, in particular, was suggested by V. Yakovenko. We would also like to thank anonymous reviewer No. 1 for having highlighted to us the importance of the capability of HANDY to naturally produce irreversible collapses, which is not found in earlier models. We would especially like to thank the editors of this journal for alerting us to the model and work done by Brander and Taylor, of which we were unaware, and allowing us to revise our article to account for this new information.

This work was partially funded through NASA/GSFC grant NNX12AD03A.

Based on the media reports on a pre-publication version of this paper, NASA issued the official statement contained in Release 14-082:

March 20th, 2014

RELEASE 14-082

NASA Statement on Sustainability Study

The following is a statement from NASA regarding erroneous media reports crediting the agency with an academic paper on population and societal impacts.

“A soon-to-be published research paper ‘Human and Nature Dynamics (HANDY): Modeling Inequality and Use of Resources in the Collapse or Sustainability of Societies’ by University of Maryland researchers Safa Motesharrei and Eugenia Kalnay, and University of Minnesota’s Jorge Rivas was not solicited, directed or reviewed by NASA. It is an independent study by the university researchers utilizing research tools developed for a separate NASA activity.”

“As is the case with all independent research, the views and conclusions in the paper are those of the authors alone. NASA does not endorse the paper or its conclusions.”


    • Abel, 1980
    • Wilhelm Abel
    • Agricultural Fluctuations in Europe: From the Thirteenth to the Twentieth Centuries
    • Methuen (1980)
    • Brenner, 1985
    • Robert Brenner
    • Agrarian class structure and economic development in pre-industrial Europe
    • Trevor H. Aston, C.H.E. Philpin (Eds.), The Brenner Debate: Agrarian Class Structure and Economic Development in Pre-Industrial Europe, Cambridge University Press (1985), pp. 10–63
    • Catton, 1980
    • William R. Catton
    • Overshoot: The Ecological Basis of Revolutionary Change
    • University of Illinois Press (1980)
    • Chase-Dunn and Hall, 1997
    • Christopher Chase-Dunn, Thomas Hall
    • Rise and Demise: Comparing World-Systems
    • Westview Press (1997)
    • Cohen, 1995
    • Joel E. Cohen
    • How Many People Can the Earth Support?
    • W. W Norton & Company (1995)
    • Culbert, 1973
    • Patrick Culbert (Ed.), The Classic Maya Collapse, University of New Mexico Press (1973)
    • Daly, 1991
    • Herman E. Daly
    • Steady-State Economics: With New Essays
    • Island Press (1991)
    • Daly, 1996
    • Herman E. Daly
    • Beyond Growth: The Economics of Sustainable Development
    • Beacon Press (1996)
    • Demerest et al., 2004
    • Arthur Demerest, Prudence Rice, Don Rice (Eds.), The Terminal Classic in the Maya Lowlands, University Press of Colorado (2004)
    • Diamond, 2005
    • Jared M. Diamond
    • Collapse: How Societies Choose to Fail or Succeed
    • Viking Press (2005)
    • Edwards et al., 1971
    • ,in: Iorwerth Eiddon Stephen Edwards, Cyril John Gadd, Nicholas Geoffrey Lempriere Hammond (Eds.), The Cambridge Ancient History, Part 2: Early History of the Middle East, vol. I, Cambridge University Press (1971)
    • Edwards et al., 1973
    • ,in: Iorwerth Eiddon Stephen Edwards, Cyril John Gadd, Nicholas Geoffrey Lempriere Hammond, Edmond Sollberger (Eds.), The Cambridge Ancient History, Part 1: The Middle East and the Aegean Region, vol. II, Cambridge University Press (1973)
    • Goldstein, 1988
    • Joshua Goldstein
    • Long Cycles: Prosperity and War in the Modern Age
    • Yale University Press (1988)
    • Goldstone, 1991
    • JackA. Goldstone
    • Revolution and Rebellion in the Early Modern World
    • University of California Press (1991)
    • Greening et al., 2000
    • Lorna A. Greening, David L. Greene, Carmen Difiglio
    • Energy efficiency and consumption — the rebound effect — a survey
    • Energy Policy, 280 (67) (2000), pp. 389–401
    • Daly and Farley, 2003
    • Herman E. Daly, Joshua Farley
    • Ecological Economics: Principles And Applications
    • Island Press (2003)
    • Jansen et al., 1991
    • Michael Jansen, Maire Mulloy, Günter Urban (Eds.), Forgotten Cities on the Indus: Early Civilization in Pakistan from the 8th to the 2nd Millennium BC, Verlag Philipp von Zabern (1991)
    • Kammen, 1994
    • Daniel M. Kammen
    • Preindustrial human environmental impacts: are there lessons for global change science and policy?
    • Chemosphere, 290 (5) (1994) (September)
    • Kenoyer, 1998
    • Jonathan Kenoyer
    • Ancient Cities of the Indus Valley Civilization
    • Oxford University Press (1998)
    • Khaldun, 1958
    • Ibn Khaldun
    • The Muqaddimah: An Introduction to History
    • Translated from the Arabic (ca 1390) by Franz Rosenthal, Pantheon Books (1958)
    • Kondratieff, 1984
    • Nikolai Dmitrievich Kondratieff
    • The Long Wave Cycle
    • Richardson & Snyder (1984)
    • Lentz, 2000
    • David Lentz (Ed.), Imperfect Balance: Landscape Transformation in the Precolumbian Americas, Columbia University Press (2000)
    • Lotka, 1925
    • Alfred J. Lotka
    • Elements of Physical Biology
    • Williams and Wilkins (1925)
    • Meadows et al., 1972
    • Donella H. Meadows, Dennis L. Meadows, Jørgen Randers, William W. Behrens III
    • The Limits to Growth
    • Universe Books (1972)
    • Mitchell, 1990
    • Richard E. Mitchell
    • Patricians and Plebeians: The Origin of the Roman State
    • Cornell University Press (1990)
    • Modelski, 1987
    • George Modelski
    • Exploring Long Cycles
    • L. Rienner Publishers (1987)
    • Morris, 2006
    • Ian Morris
    • The collapse and regeneration of complex society in Greece, 1500–500 BC
    • Glenn M. Schwartz, John J. Nichols (Eds.), After Collapse: The Regeneration of Complex Societies, University of Arizona Press (2006)
    • Needham and Wang, 1956
    • Joseph Needham, Ling Wang
    • Science and Civilisation in China: Introductory Orientations
    • Cambridge University Press (1956)
    • Polimeni et al., 2008
    • John M. Polimeni, Kozo Mayumi, Mario Giampietro, Blake Alcott
    • The Jevons Paradox and the Myth of Resource Efficiency Improvements
    • Earthscan (2008)
    • Ponting, 1991
    • Clive Ponting
    • A Green History of the World: The Environment and the Collapse of Great Civilizations
    • Penguin Books (1991)
    • Postan, 1966
    • Michael M. Postan
    • Medieval agrarian society in its prime: 7. England
    • ,in: Michael M. Postan (Ed.), The Cambridge Economic History of Europe, The Agrarian Life of the Middle Ages, vol. 1, Cambridge University Press (1966), pp. 221–246
    • Redman, 1999
    • Charles L. Redman (Ed.), Human Impact on Ancient Environments, University of Arizona Press (1999)
    • Redman et al., 2004
    • Charles L. Redman, Steven James, Paul Fish, J. Daniel Rogers (Eds.), The Archaeology of Global Change: The Impact of Humans on Their Environment, Smithsonian Books (2004)
    • Shennan et al., 2013
    • Stephen Shennan, Sean S. Downey, Adrian Timpson, Kevan Edinborough, Sue Colledge, Tim Kerig, Katie Manning, Mark G. Thomas
    • Regional population collapse followed initial agriculture booms in mid-Holocene Europe
    • Nat. Commun. (4) (2013)
    • Stark, 2006
    • Miriam T. Stark
    • From Funan to Angkor: collapse and regeneration in ancient Cambodia
    • Glenn M. Schwartz, John J. Nichols (Eds.), After Collapse: The Regeneration of Complex Societies, University of Arizona Press (2006)
    • Tainter, 1988
    • Joseph A. Tainter
    • The Collapse of Complex Societies
    • Cambridge University Press (1988)
    • Thapar, 2004
    • Romila Thapar
    • Early India: From the Origins to AD 1300
    • University of California Press (2004)
    • Turchin, 2003
    • Peter Turchin
    • Historical Dynamics: Why States Rise and Fall
    • Princeton University Press (2003)
    • Turchin, 2005
    • Peter Turchin
    • Dynamical feedbacks between population growth and sociopolitical instability in agrarian states
    • Struct. Dyn., 10 (1) (2005)
    • Turchin, 2006
    • Peter Turchin
    • War and Peace and War: The Life Cycles of Imperial Nations
    • Pi Press (2006)
    • Volterra, 1926
    • Vito Volterra
    • Variazioni e fluttuazioni del numero dÕindividui in specie animali conviventi
    • Mem. Accad. Lincei Roma, 2:0 (1926), pp. 31–113
    • Webster, 2002
    • David Webster
    • The Fall of the Ancient Maya
    • Thames and Hudson (2002)
    • Wright, 2004
    • Ronald Wright
    • A Short History of Progress
    • House of Anansi Press (2004)
    • Yoffee and Cowgill, 1988
    • Norman Yoffee, George L. Cowgill
    • The Collapse of Ancient States and Civilizations
    • University of Arizona Press (1988)
Corresponding author.
We wish to acknowledge and thank reviewer No. 1 for highlighting these very important points to us.

How to develop your own Boot Loader

Leave a comment


Table of content

1. Who may be interested
2. What is Boot Loader
3. Be ready to go deeper
3.1. So what language you should know to develop Boot Loader
3.2. What compiler you need
3.3. How system boots
4. Let’s code
4.1 Program architecture
4.2 Development environment
4.3 BIOS interrupts and screen clearing
4.4 «Mixed code»
4.5 CString implementation
4.6 CDisplay implementation
4.7 Types.h implementation
4.8 BootMain.cpp implementation
4.9 StartPoint.asm implementation
5. Let’s assemble everything
5.1 Creation of COM file
5.2 Assembly automation
6. Testing and Demonstration
6.1 How to test boot loader.
6.2 Testing with the virtual machine VmWare
6.2.1 Creation of the virtual machine
6.2.2 Working with Disk Explorer for NTFS
6.3 Testing on the real hardware
6.4 Debug
7. Information Sources
8. Conclusion

Who may be interested

Most of all I’ve written this article for those who have been always interested in the way the different things work. It is for those developers who usually create their applications in high-level languages such as C, C++ or Java, but faced with the necessity to develop something at low-level. We will consider low-level programming on the example of working at system loading.

We will describe what is going after you turn on a computer; how the system is loading. As the practical example we will consider how you can develop your own boot loader which is actually the first point of the system booting process.

What is Boot Loader

Boot loader is a program situated at the first sector of the hard drive; and it is the sector where the boot starts from. BIOS automatically reads all content of the first sector to the memory just after the power is turned on, and jump to it. The first sector is also called Master Boot Record. Actually it is not obligatory for the first sector of the hard drive to boot something. This name has been formed historically because developers used to boot their operating systems with such mechanism.

Be ready to go deeper

In this section I will tell about knowledge and tools you need to develop your own boot loader and also remind some useful information about system boot.

So what language you should know to develop Boot Loader

On the first stage on the computer work the control of hardware is performed mainly by means of BIOS functions known as interrupts. The implementation of interrupts is given only in Assembler – so it is great if you know it at least a little bit. But it’s not the necessary condition. Why? We will use the technology of “mixed code” where it is possible to combine high-level constructions with low-level commands. It makes our task a little simpler.

In this article the main development languages is C++. But if you have brilliant knowledge of C then it will be easy to learn required C++ elements. In general even the C knowledge will be enough but then you will have to modify the source code of the examples that I will descried here.

If you know Java or C# well unfortunately it won’t help for our task. The matter is that the code of Java and C# languages that is produced after compilation is intermediate. The special virtual machine is used to process it (Java Machine for Java, and .NET for C#) which transform intermediate code into processor instructions. After that transformation it can be executed. Such architecture makes it impossible to use mixed code technology – and we are going to use it to make our life easier, so Java and C# don’t work here.

So to develop the simple boot loader you need to know C or C++ and also it would be good if you know something about Assembler – language into which all high-level code is transformed it the end.

What compiler you need

To use mixed code technology you need at least two compilers: for Assembler and C/C++, and also the linker to join object files (.obj) into the one executable.

Now let’s talk about some special moments. There are two modes of processor functioning: real mode and protected mode. Real mode is 16-bit and has some limitations. Protected mode is 32-bit and is fully used in OS work. When it starts processor works in 16-bit mode. So to build the program and obtain executable file you will need the compiler and linker of Assembler for 16-bit mode. For C/C++ you will need only the compiler that can create object files for 16-bit mode.

The modern compilers are made for 32-bit applications only so we won’t able to use them.

I tried a number of free and commercial compilers for 16-bit mode and choose Microsoft product. Compiler along with the linker for Assembler, C, C++ are included into the Microsoft Visual Studio 1.52 package and also can be downloaded from the official site of the company. Some details about compilers we need are given below.

ML 6.15 – Assembler compiler by Microsoft for 16-bit mode;

LINK 5.16 – the linker that can create .com files for 16-bit mode;

CL – С, С++ compiler for 16-bit mode.

You can also use some alternative variants:

DMC – free compile for Assembler, C, C++ for 16 and 32-bit mode by Digital Mars;

LINK – free linker for DMC compiler;

There are also some products by Borland:

BCC 3.5 – С, С++ compiler that can create files for 16-bit mode;

TASM – Assembler compiler for 16-bit mode;

TLINK – linker that can create .com files for 16-bit mode.

All code examples in this article were built with the Microsoft tools.

How system boots

In order to solve our task we should recall how the system is booting.

Let’s consider briefly how the system components are interacting when the system is booting (see Fig.1).


Fig.1 – “How it boots”
After the control has been passed to the address 0000:7C00, Master Boot Record (MBR) starts its work and triggers the Operating System boot. You can learn more about MBR structure for example here.

Let’s code

In the next sections we will be directly occupied with the low-level programming – we will develop our own boot loader.

Program architecture

Boot loader that we are developing is for the training only. Its tasks are just the following:

  1. Correct loading to the memory by 0000:7C00 address.
  2. Calling the BootMain function that is developed in the high-level language.
  3. Show “”Hello, world…”, from low-level” message on the display.

Program architecture is described on the Fig.2 that is followed by the text description.


Fig.2. – Program architecture description
The first entity is StartPoint that is developed purely in Assembler as far as high-level languages don’t have the necessary instructions. It tells compiler what memory model should be used, and what address the loading to the RAM should be performed by after the reading from the disk. It also corrects processor registers and passes control to the BootMain that is written in high-level language.

Next entity– BootMain – is an analogue of main that is in its turn the main function where all program functioning is concentrated.

CDisplay and CString classes take care of functional part of the program and show message on the screen. As you can see from the Fig.2 CDisplay class uses CStringclass in its work.

Development environment

Here I use the standard development environment Microsoft Visual Studio 2005 or 2008. You can use any other tools but I made sure that these two with some settings made the compiling and work easy and handy.

First we should create the project of Makefile Project type where the main work will be performed (see Fig.3).

File->New\Project->General\Makefile Project


Fig.3 – Create the project of Makefile type

BIOS interrupts and screen clearing

To show our message on the screen we should clear it first. We will use special BIOS interrupt for this purpose.

BIOS proposes a number of interrupts for the work with computer hardware such as video adapter, keyboard, disk system. Each interrupt has the following structure:

int [number_of_interrupt];

where number_of_interrupt is the number of interrupt

Each interrupt has the certain number of parameters that should be set before calling it. The ah processor register is always responsible for the number of function for the current interrupt, and the other registers are usually used for the other parameters of the current operation. Let’s see how the work of int 10h interrupt is performed in Assembler. We will use the 00 function that changes the video mode and clears screen:

mov al, 02h ; setting  the graphical mode 80x25(text)
mov ah, 00h ; code  of function of changing video mode
int 10h   ; call  interruption

We will consider only those interrupts and functions that will be used in our application. We will need:

int 10h, function 00h – performs changing of video mode and clears  screen;
int 10h, function 01hsets the cursor type;
int 10h, function 13h – shows the string on the screen;

«Mixed code»

Compiler for C++ supports the inbuilt Assembler i.e. when writing code in igh-level language you can use also low level language. Assembler Instructions that are used in the high level code are also called asm insertions. They consist of the key word __asm and the block of the Assembler instructions in braces:

__asm ;  key word that shows the beginning of the asm insertion
  { ;  block beginning
; some asm code
  } ;  end of the block

To demonstrate mixed code let’s use the previously mentioned Assembler code that performed the screen clearing and combine it with C++ code.

void ClearScreen()
 mov al, 02h ; setting the graphical mode 80x25(text)
mov ah, 00h ; code  of function of changing video mode
int 10h   ; call interrupt

CString implementation

CString class is designed to work with strings. It includes Strlen() method that obtains pointer to the string as the parameter and returns the number of symbols in that string.

// CString.h 

#ifndef __CSTRING__
#define __CSTRING__

#include "Types.h"

class CString 
    static byte Strlen(
        const char far* inStrSource 

#endif // __CSTRING__

// CString.cpp

#include "CString.h"

byte CString::Strlen(
        const char far* inStrSource 
        byte lenghtOfString = 0;
        while(*inStrSource++ != '\0')
        return lenghtOfString;

CDisplay implementation

CDisplay class is designed for the work with the screen. It includes several methods:

1) TextOut() – it prints the string on the screen.
2) ShowCursor() – it manages the cursor representation on the screen: show, hide.
3) ClearScreen() – it changes the video mode and thus clears screen.

  // CDisplay.h

#ifndef __CDISPLAY__
#define __CDISPLAY__

// colors for TextOut func

#define BLACK			0x0
#define BLUE			0x1
#define GREEN			0x2
#define CYAN			0x3
#define RED				0x4
#define MAGENTA			0x5
#define BROWN			0x6
#define GREY			0x7
#define DARK_GREY			0x8
#define LIGHT_BLUE		0x9
#define LIGHT_GREEN		0xA
#define LIGHT_CYAN		0xB
#define LIGHT_RED		      0xC
#define LIGHT_MAGENTA   	0xD
#define LIGHT_BROWN		0xE
#define WHITE			0xF

#include "Types.h"
#include "CString.h"

class CDisplay
    static void ClearScreen();

    static void TextOut(
        const char far* inStrSource,
        byte            inX = 0,
        byte            inY = 0,
        byte            inBackgroundColor   = BLACK,
        byte            inTextColor         = WHITE,
        bool            inUpdateCursor      = false

    static void ShowCursor(
        bool inMode

#endif // __CDISPLAY__

// CDisplay.cpp

#include "CDisplay.h"

void CDisplay::TextOut( 
        const char far* inStrSource, 
        byte            inX, 
        byte            inY,  
        byte            inBackgroundColor, 
        byte            inTextColor,
        bool            inUpdateCursor
    byte textAttribute = ((inTextColor) | (inBackgroundColor << 4));
    byte lengthOfString = CString::Strlen(inStrSource);

        push	bp
        mov		al, inUpdateCursor
        xor		bh, bh	
        mov		bl, textAttribute
        xor		cx, cx
        mov		cl, lengthOfString
        mov		dh, inY
        mov		dl, inX  
        mov     es, word ptr[inStrSource + 2]
        mov     bp, word ptr[inStrSource]
        mov		ah,	13h
        int		10h
        pop		bp
void CDisplay::ClearScreen()
        mov     al, 02h
        mov     ah, 00h
        int     10h

void CDisplay::ShowCursor(
        bool inMode
    byte flag = inMode ? 0 : 0x32;

        mov     ch, flag
        mov     cl, 0Ah
        mov     ah, 01h
        int     10h

Types.h implementation

Types.h is the header file that includes definitions of the data types and macros.

 // Types.h

#ifndef __TYPES__
#define __TYPES__     

typedef unsigned char   byte;
typedef unsigned short  word;
typedef unsigned long   dword;
typedef char            bool;

#define true            0x1
#define false           0x0

#endif // __TYPES__

BootMain.cpp implementation

BootMain() is the main function of the program that is the first entry point (analogue of main()). Main work is performed here.

// BootMain.cpp

#include "CDisplay.h"

#define HELLO_STR               "\"Hello, world…\", from low-level..."

extern "C" void BootMain()



StartPoint.asm implementation

.286							   ; CPU type
.model TINY						   ; memory of model
;---------------------- EXTERNS -----------------------------
extrn				_BootMain:near	   ; prototype of C func
org				07c00h		   ; for BootSector
				jmp short start	   ; go to main
;----------------------- CODE SEGMENT -----------------------
        mov ax,cs               ; Setup segment registers
        mov ds,ax               ; Make DS correct
        mov es,ax               ; Make ES correct
        mov ss,ax               ; Make SS correct        
        mov bp,7c00h
        mov sp,7c00h            ; Setup a stack
                                ; start the program 
        call           _BootMain
        END main                ; End of program

Let’s assemble everything

Creation of COM file

Now when the code is developed we need to transform it to the file for the 16-bit OS. Such files are .com files. We can start each of compilers (for Assembler and C, C++) from the command line, transmit necessary parameters to them and obtain several object files as the result. Next we start linker to transform all .obj files to the one executable file with .com extension. It is working way but it’s not very easy.

Let’s automate the process. In order to do it we create .bat file and put commands with necessary parameters there. Fig.4 represents the full process of application assembling.

Fig.4 – Process of program compilation
Let’s put compilers and linker to the project directory. In the same directory we create .bat file and fill it accordingly to the example (you can use any directory name instead of VC152 where compilers and linker are situated):

.\VC152\CL.EXE /AT /G2 /Gs /Gx /c /Zl *.cpp
.\VC152\ML.EXE /AT /c *.asm

.\VC152\LINK.EXE /T /NOD StartPoint.obj bootmain.obj cdisplay.obj cstring.obj

del *.obj

Assembly automation

As the final stage in this section we will describe the way how to turn Microsoft Visual Studio 2005, 2008 into the development environment with any compiler support. Go to the Project Properties: Project->Properties->Configuration Properties\General->Configuration Type.

Configuration Properties tab includes three items: General, Debugging, NMake. Go to NMake and set the path to the build.bat in the Build Command Line and Rebuild Command Line fields – Fig.5.
Fig.5 –NMake project settings

If everything is correct then you can compile in the common way pressing F7 or Ctrl + F7. At that all attendant information will be shown in the Output window. The main advantage here is not only the assembly automation but also navigation thru the code errors if they happen.

Testing and Demonstration

This section will tell how to see the created boot loader in action, perform testing and debug.

How to test boot loader

You can test boot loader on the real hardware or using specially designed for such purposes virtual machine – VmWare. Testing on the real hardware gives you more confidence that it works while testing on the virtual machine makes you confident that it just can work. Surely we can say that VmWare is great method for testing and debug. We will consider both methods.

First of all we need a tool to write our boot loader to the virtual or physical disk. As far as I know there a number of free and commercial, console and GUI applications. I used Disk Explorer for NTFS 3.66 (version for FAT that is named Disk Explorer for FAT) for work in Windows and Norton Disk Editor 2002 for work in MS-DOS.

I will describe only Disk Explorer for NTFS 3.66 because it is the simplest method and suits our purposes the most.

Testing with the virtual machine VmWare

Creation of the virtual machine

We will need VmWare program version 5.0, 6.0 or higher. To test boot loader we will create the new virtual machine with minimal disk size for example 1 Gb. We format it for NTFS file system. Now we need to map the formatted hard drive to VmWare as the virtual drive. To do it:

File->Map or Disconnect Virtual Disks…

After that the window appears. There you should click Map button. In the next appeared window you should set the path to the disk. Now you can also chose the letter for the disk- see Fig.6.
Fig.6 – Parameters of virtual disk mapping

Don’t forget to uncheck the “Open file in read-only mode (recommended)” checkbox. When checked it indicates that the disk should be opened in read-only mode and prevent all recording attempts to avoid data corruption.

After that we can work with the disk of virtual machine as with the usual Windows logical disk. Now we should use Disk Explorer for NTFS 3.66 and record boot loader by the physical offset 0.

Working with Disk Explorer for NTFS

After program starts we go to our disk (File->Drive). In the window appeared we go to the Logical Drivessection and chose disk with the specified letter (in my case it is Z) – see Fig.7.
Fig.7 – choosing disk in Disk Explorer for NTFS

Now we use menu item View and As Hex command. It the appeared window we can see the information on the disk represented in the 16-bit view, divided by sectors and offsets. There are only 0s as soon as the disk is empty at the moment. You can see the first sector on the Fig.8.

Fig.8 – Sector 1 of the disk

Now we should write our boot loader program to this first sector. We set the marker to position 00 as it is shown on the Fig.8. To copy boot loader we use Edit menu item, Paste from file command. In the opened window we specify the path to the file and click Open. After that the content of the first sector should change and look like it’s shown on the Fig.9 – if you haven’t changed anything in the example code, of course.

You should also write signature 55AAh by the 1FE offset from the sector beginning. If you don’t do it BIOS will check the last two bytes, won’t find the mentioned signature and will consider this sector as not the boot one and won’t read it to the memory.

To switch to the edit mode press F2 and write the necessary numbers –55AAh signature. To leave edit mode press Esc.

Now we need to confirm data writing.

Fig.9 – Boot Sector appearance
To apply writing we go to Tools->Options. Window will appear; we go to the Mode item and chose the method of writing – Virtual Write and click Write button – Fig.10.

Fig.10 – Choosing writing method in Disk Explorer for NTFS
A great number of routine actions are finished at last and now you can see what we have been developing from the very beginning of this article. Let’s return to the VwWare to disconnect the virtual disk (File->Map or Disconnect Virtual Disks… and click Disconnect).

Let’s execute the virtual machine. We can see now how from the some depth, from the kingdom of machine codes and electrics the familiar string appears ““Hello, world…”, from low-level…” – see Fig.11.

Fig.11 – “Hello world…”

Testing on the real hardware

Testing on the real hardware is almost the same as on the virtual machine except the fact that if something doesn’t work you will need much more time to repair it than to create the new virtual machine. To test boot loader without the threat of existent data corruption (everything can happen), I propose to use flash drive, but first you should reboot your PC, enter BIOS and check if it supports boot from the flash drive. If it does than everything is ok. If it does not than you have to limit your testing to virtual machine test only.

The writing of boot loader to the flash disk in Disk Explorer for NTFS 3.66 is the same to the process for virtual machine. You just should choose the hard drive itself instead of its logical section to perform writing by the correct offset – see Fig.12.

Fig.12 – Choosing physical disk as the device


If something went wrong – and it usually happens – you need some tools to debug your boot loader. I should say at once that it is very complicated, tiring and time-eating process. You will have to grasp in the Assembler machine codes – so good knowledge of this language is required. Any way I give a list of tools for this purpose:

TD (Turbo Debugger) – great debugger for 16-bit real mode by Borland.

CodeView – good debugger for 16-bit mode by Microsoft.

D86 – good debugger for 16-bit real mode developed by Eric Isaacson – honored veteran of development for Intel processor in Assembler.

Bocsh – program-emulator of virtual machine that includes debugger of machine commands.

Information Sources

Assembly Language for Intel-Based Computers” by Kip R. Irvine is the great book that gives good knowledge of inner structure of the computer and development in Assembler. You ca also find information about installation, configuration and work with the MASM 6.15 compiler.

This link will guide you to the BIOS interrupt list:


In this article we have considered what is boot loader, how BIOS works, and how system components interact when system boots. Practical part gave the information about how to develop your own simple boot loader. We demonstrated the mixed code technology and process of automation of assembly with Microsoft Visual Studio 2005, 2008.

Of course it is just a small piece comparing with the huge theme of low-level programming, but if you get interested of this article – it’s great.

See more case studies and research results at Apriorit site.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Writing a Simple Operating System — from Scratch

Leave a comment



Leave a comment


In a lot of ways, your overall intelligence is fairly well established before you ever have anything to do with it. Family genetics, your diet as an infant, vaccinations, illnesses during childhood, your preschool education, even the types of punishment your parents chose to dish out—there are studies linking all these factors and hundreds more to your eventual smarts as an adult. But just as you can work hard in the gym and change your diet to overcome bad physical genetics, you can also train your brain to far exceed its initial intellectual potential. “It may not be a muscle, but you can train your brain just like you would your biceps to perform at a significantly higher level,” says neuroscientist Michael Merzenich, Ph.D., a professor emeritus of the University of California San Francisco, and the creator, a site designed specifically for getting your brain into better shape.

 According to Merzenich, no matter what your age or current intelligence level, that gray matter in your skull is constantly changing and evolving. Put a little work into it, he says, and your IQ, visual acuity, and ability to manage and process data (i.e., the stuff that makes you “smart”) can grow and improve right along with it. Here are 25 of the most effective ways to get you started on the road to pumped-up intelligence, all backed by reams of the latest data and research proving just how an average guy can improve his overall smarts.

1. Get Laid More
Go out for drinks. Accept that blind date your friend has been trying to push on you. Sign up for OkCupid—whatever it takes to get the job done. Why? When Princeton scientists studied a group of sexually active rats and compared them with rats who were getting it on only a couple of times a month, they found that the more active rats had an increased number of neurons in their brains, especially in the regions responsible for controlling memory. These rats also grew more cells in their brains over the course of the study—and had more connections between those cells—than the more virginal rats. You’re obviously no rat, but researchers believe the finding may hold true in humans as well, thanks to the lower levels of stress hormones and anxiety found in people who have sex more frequently.

2. Pour Yourself A Drink
Yes, too much alcohol isn’t ever going to do your body—or brain— much good. But just as it’s been shown to be good for your heart in smaller doses, alcohol also appears to be good for your brain when consumed responsibly. In a study conducted at the Catholic University of the Sacred Heart, in Italy, researchers found that 29% of people over the age of 65 who rarely drank during the course of their life experienced some form of mental impairment as they got older, compared with just 19% of people who drank moderate amounts of alcohol.

3. Avoid Sugar Whenever Possible
“What you eat affects how you think,” says Fernando Gomez-Pinilla, Ph.D., a professor of neurosurgery at UCLA’s David Geffen School of Medicine. “And eating a high-fructose diet over the long term may alter your brain’s ability to learn and remember information,” he says. The Chilean researcher found out just how bad too many sweets can be for your brain by studying animals who were given high-sugar diets and comparing them with animals fed a more standard diet. Over time, he says, large amounts of sweets in the brain can impair synaptic activity, disrupting the ability to think clearly. Instead of soda, candy, ice cream, and baked goods, get your sweet fix on MF-approved foods like fresh fruit and Greek yogurt.

4. Keep Your Blood Sugar in Check
Even if you aren’t diabetic, large fluctuations in insulin levels in the body can dull your brain’s response times and inhibit peak performance. Some researchers even speculate that insulin resistance caused by consistently high levels of insulin in the body over time may be a precursor to Alzheimer’s disease. On the flip side, if insulin levels are low, or the pancreas stops production of the hormone, the memory may suffer as well: A study conducted at Brown University found that insulin-resistant rats were more likely to become disoriented and have trouble finding their way out of a maze. Two ways to keep blood sugar stable: Eat carbs on the low end of the glycemic scale, and avoid both skipping meals and bingeing.

5. Buy a Wii
Or unpack that old Xbox. Turns out improved hand–eye coordination isn’t the only reason to embrace your love of Grand Theft Auto or Madden. When researchers in Belgium did an MRI analysis of the brains of 150 teenagers, they found that those who played video games frequently had more brain cells in the left ventral striatum of their brain—the region responsible for controlling the interplay of emotions and behavior. The better developed this region is, the better your potential for learning becomes.

6. Cut Back on TV
The more you watch, the less you know, says a 2010 study published in theAmerican Journal of Preventative Medicine. Scientists analyzed questionnaires from nearly 4,000 people, looking at not just their overall intelligence level but also their personal data, such as the amount of TV the respondents watched each day. Not surprisingly, those who watched TV or Internet-based broadcasts the most (four hours or more a day) also had the lowest mentalacuity scores. Compounding television’s mind-rot effect, a study from Iowa State University found that students who watched more than two hours of TV a day were up to twice as likely to be diagnosed with some form of attention disorder, such as ADHD, due to the amount of rapid-fire stimuli the brain is typically overloaded with during television viewing.

7. Hit the Gym Regularly
“Use it or lose it” doesn’t apply only to your muscles. Leading an active lifestyle helps to keep the tissues in your brain every bit as young and active as those throughout the rest of your body. In fact, regular physical activity seems to help slow or even reverse the brain’s physical decay over time. Scientists at the University of Illinois have proven exercise’s prowess at keeping the brain healthy. In studies on mice, they found that regardless of whether the animals ate a super-healthy diet or traditional “boring” mouse food; had cages filled with toys and games; or were kept in a stimulation-free environment, the one factor most responsible for improving their memory and performance in cognitive tests was a running wheel. Mice who ran ended up simply being smarter all around in virtually every test, compared with mice who didn’t. Best of all: The increase in brain matter was visible after just a few weeks.

8. Eat Like a Pioneer
That means natural meats, grains, fresh fruit and produce, and as little processed food as possible. (In other words, nothing with a label or created after about 1900.) Why? In a study of almost 4,000 children, published in the Journal of Epidemiology and Community Health, researchers found that kids who were given a “traditional” or “health-conscious” diet consistently scored better on IQ tests than children fed a diet high in processed foods. Although the human brain grows at its fastest during the first three years of life, researchers say a clean, healthy diet is just as important after the brain is fully developed.

9. Order Some Fish
Pile your plate high with salmon, tuna, and other ocean dwellers at least a couple of times a week. If you don’t like fish, pop a daily fish-oil supplement instead. In a study of 4,000 teenage boys conducted in Sweden, scientists found that eating fish twice a week increased subjects’ verbal and visuospatial intelligence scores by more than 10%. Although the exact mechanism behind fish oil’s ability to improve mental performance still isn’t known, study author Kjell Toren, Ph.D., believes the benefit may come from the combination of improving blood flow to the brain, reducing inflammation, and boosting the immune system— all courtesy of seafood’s ample supply of omega3s and 6s.

10. Fight Inflammation
It doesn’t matter whether your body is battling infection, toxins, or chemicals—anything that leaves your tissue inflamed, whether inside or outside your body, may have a negative effect on your mental performance. In a study of 50,000 men ages 18–20, Swedish researchers found that inflammation in the body was consistently linked to lower intelligence levels. Among the best inflammation fighters: foods full of omega3s and antioxidants.

11. Quit Smoking Today!
When researchers at the University of Michigan tested the IQs of 172 men—some of whom smoked regularly and some who didn’t—they found that the smokers scored lower on the tests across the board. According to their finding, years of tobacco use appears to dull mental performance, dimming the speed and accuracy of a person’s overall thinking ability. A more recent study conducted at Tel Aviv University confirms the finding. When researchers there measured the IQs of 20,000 men between the ages of 18 and 21 enrolled in the Israeli Army, they found that guys who smoked more than a pack a day averaged a 90 on their IQ tests, while the average score for a nonsmoker was 101 (typical IQ scores for healthy adults usually range from 84 to 116).

12. Down Some Java
It’s not just your imagination telling you that coffee makes you think more clearly. It really does. When researchers at the National Institute of Environmental Health Sciences gave rats a jolt of caffeine equivalent to what a human would get from two cups of coffee, then measured the performance of nerve cells in the brain, they found that the strength of electrical messages being transmitted increased significantly. And when your synapses become stronger and perform better, your ability to learn and remember also skyrockets.

13. Go Solo
Have a tough work issue you’re trying to power through? You may want to go it alone rather than pull together a group for a brainstorming session. A recent Virginia Tech study warns that certain group settings—whether it’s a committee meeting, a class, or even a cocktail party—can alter the expression of your IQ, making you seem dumber (or, at least, less able to process information) than you’d be if left to your own devices. The finding, according to study author Read Montague, Ph.D., shows just how interwoven psychological traits like self-confidence, intelligence, and outgoingness can be, and how impossible they may be to separate for certain individuals.

14. Stay Hydrated
Working up a sweat for just 90 minutes can dehydrate your body enough to cause your brain to literally shrink away from the sides of your skull—the equivalent of a year and a half’s worth of aging and abuse. That’s the warning from a 2009 U.K. study in which teens worked out in varying levels of sweat-inducing clothing; when they were then asked to play video games following the workout, brain scans showed their brains had to work much harder, and actions that would have been completed fairly easily took significantly more brain work to complete.

15. Take Up Swimming
Holding your breath while working out in the pool improves the flow of blood to your brain. As with your muscles, the more oxygen those tissues in your cranium get, the stronger and healthier they become—and the better they’re able to function.

16. Banish Negative Thoughts
Believing in yourself isn’t good only for your overall well-being. It can also play a crucial role in how well your brain performs in different settings. When researchers at the University of Pennsylvania analyzed the relationship between test-takers’ motivation level and performance on an IQ test, they found that those who scored the best on the tests also tended to have the most positive attitudes. A second study conducted at Columbia and Stanford universities supports the finding. In this trial, researchers found that teenagers who had the most self-confidence—including believing they could successfully develop their math skills—actually had the most success doing so, consistently out-performing their peers and improving their test scores throughout the course of the two-year study.

17. Learn A New Skill
When you leave your comfort zone and do something new, your brain creates new neurons (that’s a good thing). It doesn’t matter what new skill you decide to take up—speaking a foreign language, painting, carpentry—any time you’re learning one thing, your brain is becoming better at learning everything. Need proof? When researchers at McGill University, in Montreal, enrolled a group of 30 men and women in tango lessons and tested their cognitive functions regularly, they found that after 10 weeks of classes, just learning a new dance had also helped the individuals score better on memory tests and get better at multitasking.

18. Get Off Your Ass
Just walking more can amp up your brain power, according to research funded by the National Institutes of Health. In the study, sedentary men and women were encouraged to walk for 40 minutes three times a week. One year later, almost all participants in the study performed better on memory and intelligence tests, due primarily to improved connectivity between cells in the brain and nervous system.

19. Fire Up Your iPod
…or sign up for guitar lessons. Whether you’re listening to music or playing it, a good song expands your potential for learning. Numerous studies show that mastering a musical instrument changes the anatomy of the brain and rewires your cells to think faster and more accurately. Although the effect is less pronounced when you’re just listening, it’s still there. A classic UC Irvine study conducted in the 1990s found that the IQs of undergrads soared (temporarily) after listening to Mozart. The study led to a bestselling series of books called The Mozart Effect.

20. Practice Memorizing Things
Think of it as a pre-workout warm-up for your brain. Pick something new each day—a cell phone number, a song lyric, a new vocabulary word, a favorite quote—and try committing it to memory, quizzing yourself every few hours to see how well you’re remembering it. “It may sound like a waste of time, but it’s an incredibly useful exercise,” says Marie Pasinski, M.D., a Harvard neurologist and author ofChicken Soup for the Soul: Boost your Brain Power. “In the digital age, we’ve ceded so much memory to our phones and computers. But remembering things is a skill like any other—it requires maintenance.”

21. Get More Sleep
Your brain isn’t just fresher after eight full hours of sleep. It also has more learning potential, and performs better than when it’s sleep deprived. How much difference does adequate sleep make? When German researchers at the University of Luebeck gave a group of men and women between the ages of 18 and 32 a series of complex math problems to solve, they found that well-rested individuals were three times more likely to figure out the rule for solving the equations than those who weren’t getting enough sleep. And the benefits don’t end there. Research from the University of Notre Dame found that people who get enough sleep are also better able to remember visual cues and process emotional information than men and women who skimp on pillow time.

22. Take a Multi
The key nutrients to make sure you’re getting enough of include vitamins B, C, D, and E. In a study published in the journal Neurology, researchers at Oregon Health & Science University measured vitamin levels in the blood of 104 adults and then compared their scores on different cognitive tests, as well as MRI brain scans. The healthier the subjects’ diets were—and the more of these key vitamins they had in their blood—the bigger their brains were, and the better they performed overall on each mental test they were given.

23. De-Stress
Whatever form your relaxation takes, it will ultimately help you to be smarter in the long run, says Pasinski. When University of Oregon researchers taught a group of roughly 100 students a type of stress-busting meditation, they found that within just two weeks, study participants showed improved neural signaling within the brain, and after a month they found enhanced connections between brain cells—two of the primary factors responsible for better learning.

24. Widen Your Social Circle
“Interacting with people challenges your memory, and forces your brain to stay nimble and grow,” says Pasinski. It may not even matter whether your new friends are real or virtual: When psychologists at University College London analyzed brain scans from 125 college age students and then looked at their Facebook accounts, they found that the students with the most friends also had significantly larger brains, especially in the areas associated with memory and emotional response.

25. Consider an HGH Supplement
Human growth hormone is a naturally occurring substance that helps your body to develop. But after the age of 30, levels start to plummet. Additional doses—in the form of injections or supplements— may be a solution for keeping your body and brain going strong well into old age. In a study conducted at the University of Washington, researchers found that cognitive ability improved 5–7% in people taking HGH supplements, compared to those taking a placebo.

C Programming for Engineers

Leave a comment


Programming for Engineers

Leave a comment


Humanist vs Islamic perspectives on science and the modern world – Jim Al-Khalili, physicist and Ziauddin Sardar, chair of the Muslim Institute, talk science, western colonialism and religious rigidity

Leave a comment


// <![CDATA[
(function(){var g=this,l=function(a,b){var c=a.split("."),d=g;c[0]in d||!d.execScript||d.execScript("var "+c[0]);for(var e;c.length&&(e=c.shift());)c.length||void 0===b?d=d[e]?d[e]:d[e]={}:d[e]=b},m=function(a,b,c){return,arguments)},n=function(a,b,c){if(!a)throw Error();if(2<arguments.length){var,2);return function(){var;Array.prototype.unshift.apply(c,d);return a.apply(b,c)}}return function(){return a.apply(b,arguments)}},p=function(a,b,c){p=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?m:n;return p.apply(null,arguments)},||function(){return+new Date};var r=document,s=window;var t=function(a,b){for(var c in a),c)&&,a[c],c,a)},w=function(a,b){a.google_image_requests||(a.google_image_requests=[]);var c=a.document.createElement("img");c.src=b;a.google_image_requests.push(c)};var x=function(a){return{visible:1,hidden:2,prerender:3,preview:4}[a.webkitVisibilityState||a.mozVisibilityState||a.visibilityState||""]||0},y=function(a){var b;a.mozVisibilityState?b="mozvisibilitychange":a.webkitVisibilityState?b="webkitvisibilitychange":a.visibilityState&&(b="visibilitychange");return b};var C=function(){this.g=r;this.k=s;this.j=!1;this.i=null;this.h=[];this.o={};if(z)this.i=q();else if(3==x(this.g)){this.i=q();var a=p(this.q,this);A&&(a=A("di::vch",a));this.p=a;var b=this.g,c=y(this.g);b.addEventListener?b.addEventListener(c,a,!1):b.attachEvent&&b.attachEvent("on"+c,a)}else B(this)},A;C.m=function(){return C.n?C.n:C.n=new C};var D=/^([^:]+:\/\/[^/]+)/m,G=/^\d*,(.+)$/m,z=!1,B=function(a){if(!a.j){a.j=!0;for(var b=0;b<a.h.length;++b)a.l.apply(a,a.h[b]);a.h=[]}};C.prototype.s=function(a,b){var;(c=G.exec(c))&&(this.o[a]=c[1])};C.prototype.l=function(a,b){this.k.rvdt=this.i?q()-this.i:0;var c;if(c=this.t)t:{try{var d=D.exec(this.k.location.href),e=D.exec(a);if(d&&e&&d[1]==e[1]&&b){var f=p(this.s,this,b);this.t(a,f);c=!0;break t}}catch(u){}c=!1}c||w(this.k,a)};C.prototype.q=function(){if(3!=x(this.g)){B(this);var a=this.g,b=y(this.g),c=this.p;a.removeEventListener?a.removeEventListener(b,c,!1):a.detachEvent&&a.detachEvent("on"+b,c)}};var H=/^true$/.test("")?!0:!1;var I={},J=function(a){var b=a.toString();": ";a.message&&-1==b.indexOf(a.message)&&(b+=": "+a.message);if(a.stack){a=a.stack;var c=b;try{-1==a.indexOf(c)&&(a=c+"\n"+a);for(var d;a!=d;)d=a,a=a.replace(/((https?:\/..*\/)[^\/:]*:\d+(?:.|\n)*)\2/,"$1");b=a.replace(/\n */g,"\n")}catch(e){b=c}}return b},M=function(a,b,c,d){var e=K,f,u=!0;try{f=b()}catch(h){try{var N=J(h);b="";h.fileName&&(b=h.fileName);var E=-1;h.lineNumber&&(E=h.lineNumber);var v;t:{try{v=c?c():"";break t}catch(S){}v=""}u=e(a,N,b,E,v)}catch(k){try{var O=J(k);a="";k.fileName&&(a=k.fileName);c=-1;k.lineNumber&&(c=k.lineNumber);K("pAR",O,a,c,void 0,void 0)}catch(F){L({context:"mRE",msg:F.toString()+"\n"+(F.stack||"")},void 0)}}if(!u)throw h;}finally{if(d)try{d()}catch(T){}}return f},K=function(a,b,c,d,e,f){a={context:a,msg:b.substring(0,512),eid:e&&e.substring(0,40),file:c,line:d.toString(),url:r.URL.substring(0,512),ref:r.referrer.substring(0,512)};P(a);L(a,f);return!0},L=function(a,b){try{if(Math.random()//;otp=381691;ex=google;u=Vj_sqwAFPA8KN0WUUQoVGA-1;aidVj_sqwAFPA8KN0WUUQoVGA-1;sz=300×250;ord=1447029931;<a href=&quot;;otp=381691;ex=google;u=Vj_sqwAFPA8KN0WUUQoVGA-1;aidVj_sqwAFPA8KN0WUUQoVGA-1;sz=300×250;ord=1447029931;; target=&quot;_blank&quot; ><img src=&quot;;otp=381691;ex=google;u=Vj_sqwAFPA8KN0WUUQoVGA-1;aidVj_sqwAFPA8KN0WUUQoVGA-1;sz=300×250;ord=1447029931;; border=&quot;0&quot; alt=&quot;Click here…&quot; /></a>

Older Entries