The code for this chapter is in the Jupyter notebook chap07.ipynb in the repository for this book. Open this notebook, read the code, and run the cells. You can use this notebook to work on the exercises in this chapter.
Exercise 1: Write a version of
correlate that returns the same result as
mode='same'. Hint: use the NumPy function pad.
Exercise 2: This exercise asks you to experiment with Rule 110 and some of its spaceships.
Read the Wikipedia page about Rule 110, which describes its background pattern and spaceships.
Create a Rule 110 CA with an initial condition that yields the stable background pattern. Note that the
start_string, which allows you to initialize the state of the array using a string of 1s and 0s.
Modify the initial condition by adding different patterns in the center of the row and see which ones yield spaceships. You might want to enumerate all possible patterns of n bits, for some reasonable value of n. For each spaceship, can you find the period and rate of translation? What is the biggest spaceship you can find?
What happens when spaceships collide?
Exercise 3: The goal of this exercise is to implement a Turing machine.
Read about Turing machines.
Write a class called
Turingthat implements a Turing machine. For the action table, use the rules for a 3-state busy beaver.
Write a class named
TuringViewerthat generates an image that represents the state of the tape and the position and state of the head. For one example of what that might look like.