Chapter 7. Project: Electronic Life

“The question of whether Machines Can Think . . . is about as relevant as the question of whether Submarines Can Swim.”

—Edsger Dijkstra, The Threats to Computing Science

In “project” chapters, I’ll stop pummeling you with new theory for a brief moment and instead work through a program with you. Theory is indispensable when learning to program, but it should also be accompanied by reading and understanding nontrivial programs.

Our project in this chapter is to build a virtual ecosystem, a little world populated with critters that move around and struggle for survival.

Definition

To make this task manageable, we will radically simplify the concept of a world. Namely, a world will be a two-dimensional ...

Get Eloquent JavaScript, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.