chapter 3 example from the book AI Game Programming By Example