The interlude is an introduction to the more advanced topic of a finite state machine, which should be in the tool-box of every software developer. It amounts to the simple idea of putting information in tables such that each row of the table can refer to another row in the table.

The example from the book is a map of rooms, which can be described by a table, where each row is a door (or hallway passage) from one room to another. In the code below, the table is represented by a dictionary.

Table-Driven Game States

Head,Tail = 1,0
D = {("NW",Head):"N",("N",Head):"NE",
room = "SE" # initial location
print "Starting in room", room
while True:
   cointoss = random.choice([Head,Tail])
   room = D[(room,cointoss)]
   print "moving to", room