11.6 Implementation

We will create our simulation in Python by first implementing the instance variables and methods of the classes as described previously. Once we have the classes in place, we can complete the simulation by simply creating a world, adding life-forms to it, and then allowing the life-forms to live. The longer we let the simulation run, the more interesting the results may become.

11.6.1 The World Class

We will begin by implementing the World class. Recall that the World class will maintain dimensions as well as a list of the life-forms that are present. It will also have a grid to track the life-form positions. A Turtle will be used to set the initial coordinates for the world and to draw the grid.

Implementation of the ...

Get Python Programming in Context, 3rd 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.