@@ -19,17 +19,18 @@ and instead work through a program with you. Theory is indispensable
1919when learning to program, but it should be accompanied by reading and
2020understanding non-trivial programs.
2121
22- (((electronic life project)))(((ecosystem)))Our project in this
23- chapter is to build a virtual ecosystem, a little world populated with
24- ((critter))s that move around and struggle for survival.
22+ (((artificial life)))(((electronic life)))(((ecosystem)))Our
23+ project in this chapter is to build a virtual ecosystem, a little
24+ world populated with ((critter))s that move around and struggle for
25+ survival.
2526
2627== Definition ==
2728
28- (((electronic life project )))In order to make this task manageable, we
29- will radically simplify the concept of a _((world))_. Namely, a world
30- will be a two-dimensional ((grid)) where each entity takes up one full
31- square of the grid. On every _((turn))_, the critters all get a chance
32- to take some action.
29+ (((dimensions)))((( electronic life)))In order to make this
30+ task manageable, we will radically simplify the concept of a
31+ _((world))_. Namely, a world will be a two-dimensional ((grid)) where
32+ each entity takes up one full square of the grid. On every _((turn))_,
33+ the critters all get a chance to take some action.
3334
3435(((discretization)))(((simulation)))Thus, we chop both time and space
3536into units with a fixed size: squares for space and turns for time. Of
@@ -60,7 +61,7 @@ var plan =
6061 "############################"];
6162----
6263
63- The “#” characters in this plan represent walls and rocks, and the
64+ The “#” characters in this plan represent ((wall))s and rocks, and the
6465“o” characters represent critters. The spaces, as you might have
6566guessed, are empty space.
6667
@@ -172,7 +173,7 @@ console.log(grid.get(new Vector(1, 1)));
172173
173174== A critter's programming interface ==
174175
175- (((record)))(((electronic life project )))(((interface)))Before we can
176+ (((record)))(((electronic life)))(((interface)))Before we can
176177start on the `World` ((constructor)), we must get more specific about
177178the ((critter)) objects that will be living inside it. I mentioned
178179that the world will ask the critters what actions they want to take.
@@ -263,7 +264,7 @@ when crowded into a corner by other critters).
263264
264265== The world object ==
265266
266- (((World type)))(((electronic life project )))Now we can start on the
267+ (((World type)))(((electronic life)))Now we can start on the
267268`World` object type. The ((constructor)) takes a plan (the array of
268269strings representing the world's grid, described
269270link:07_elife.html#grid[earlier]) and a _((legend))_ as arguments. A
@@ -333,7 +334,7 @@ World.prototype.toString = function() {
333334};
334335----
335336
336- (((electronic life project )))(((constructor)))(((Wall type)))A wall is
337+ (((electronic life)))(((constructor)))(((Wall type)))A (( wall)) is
337338a very simple object—it is only used for taking up space, and has no
338339`act` method.
339340
@@ -468,7 +469,7 @@ Grid.prototype.forEach = function(f, context) {
468469
469470== Animating life ==
470471
471- (((simulation)))(((electronic life project )))(((World type)))The next
472+ (((simulation)))(((electronic life)))(((World type)))The next
472473step is to write a `turn` method for the world object that gives the
473474((critter))s a chance to act. It will go over the grid using the
474475`forEach` method we just defined, looking for objects with an `act`
@@ -528,7 +529,7 @@ World.prototype.checkDestination = function(action, vector) {
528529};
529530----
530531
531- (((View type)))(((electronic life project )))First, we simply ask the
532+ (((View type)))(((electronic life)))First, we simply ask the
532533critter to act, passing it a view object that knows about the world
533534and the critter's current position in that world (we'll define `View`
534535in a link:07_elife.html#view[moment]). The `act` method returns an
@@ -607,7 +608,7 @@ in, the critters still won't be tempted to try and walk off the edges.
607608
608609== It moves ==
609610
610- (((electronic life project )))(((simulation)))We instantiated a world
611+ (((electronic life)))(((simulation)))We instantiated a world
611612object before. Now that we've added all the necessary methods, it
612613should be possible to actually make it move.
613614
@@ -763,7 +764,7 @@ endif::html_target[]
763764
764765== A more lifelike simulation ==
765766
766- (((simulation)))(((electronic life project )))To make life in our world
767+ (((simulation)))(((electronic life)))To make life in our world
767768more interesting, we will add the concepts of ((food)) and
768769((reproduction)). Each living thing in the world gets a new property,
769770`energy`, which is reduced by performing actions and increased by
@@ -816,7 +817,7 @@ LifelikeWorld.prototype.letAct = function(critter, vector) {
816817};
817818----
818819
819- (((electronic life project )))(((function,as value)))(((call
820+ (((electronic life)))(((function,as value)))(((call
820821method)))(((this)))The new `letAct` method first checks whether an
821822action was returned at all, then whether a handler function for this
822823type of action exists, and finally, whether that handler returned
@@ -917,7 +918,7 @@ actionTypes.reproduce = function(critter, vector, action) {
917918};
918919----
919920
920- (((electronic life project )))Reproducing costs twice the ((energy))
921+ (((electronic life)))Reproducing costs twice the ((energy))
921922level of the newborn critter. So we first create a (hypothetical) baby
922923using `elementFromChar` on the critter's own origin character. Once we
923924have a baby, we can find its energy level and test whether the parent
@@ -929,7 +930,7 @@ require a valid (and empty) destination.
929930
930931== Populating the new world ==
931932
932- (((Plant type)))(((electronic life project )))We now have a
933+ (((Plant type)))(((electronic life)))We now have a
933934((framework)) to simulate these more lifelike creatures. We could put
934935the critters from the old world into it, but they would just die,
935936since they don't have an ((energy)) property. So let us make new ones.
@@ -987,7 +988,7 @@ creature will look for when it searches for ((food)).
987988
988989== Bringing it to life ==
989990
990- (((electronic life project )))And that gives us enough elements to try
991+ (((electronic life)))And that gives us enough elements to try
991992our new world. Imagine the map below as a grassy valley with a herd of
992993((herbivore))s in it, some boulders, and lush ((plant)) life
993994everywhere.
0 commit comments