Original Post
My problem is probably best explained with an example. Let's consider a hypothetical simple game with AI-controlled robots battling each other in an arena. There is a basic Game object that includes the arena Map object, and a list of Robot objects. What good options do I have for updating the actions of the Robots? The robots need to know what and where the other robots are doing. They also need to know about their surroundings for pathfinding. A relatively ugly solution that worked well in my latest project was to give each Robot a pointer to the base Game object, so they could access the Map and list of Robots at will. I don't really know why this feels wrong, but it does. The other options that I can come up with are having the Game object do all the AI updates, and not letting the Robots think for themselves. This makes code horrible, but has worked for me in small projects. The other option is to create a thorough messaging system, where the Game checks what each robot can see, and sends them messages. The Robots then know about the world only through second-hand information, and try to work with that. I usually try not to fix what isn't broken, but this time I'm yearning to make an exception. I hate the Game* pointer. Of course the Game/Map/Robot is just an abstraction of the general design principle problem. As sadly, not all my games have fighting Robots.