Added code for multiagent and up to Question 4