Code for studying AIMA Chapter 3