CS 221: Completed Assignment 6 #3 (credit https://cs188.googlecode.com/svn/trunk/multiAgents.py)