   Robot Simulation - filtering objects
  There is something I cannot quite understand how to do.I have been trying to figure-out how create "robot" objects and then set them loose in a simulated world.Let's say the "world" is 10 squares wide by 10 squares wide.  If I use a 2D array to store the "world" and there are 2 "robot" objects in the world, then I have to process 98 squares i don't care about everytime I want to update the world.  The benefit is I can use the world to tell the "robot" what is around it when it wants to know this information.However, if I store the robots in their own array of robots, then when I loop through the array I know I am processing ONLY "robots" but then it is much harder for the robots to know about the rest of the world around them.How do I get around this?   
  Have the world and robot arrays separate but in the same scope. Each robot would have its own world coordinates, and update the world array to let other robots know that there is a robot in a certain position. Then you'd only have to iterate through the robot array for processing, referencing the world array using the robot world coordinates to find out what is in the robot's immediate locality.   ;Quote:Original post by Tom KnowltonThere is something I cannot quite understand how to do.I have been trying to figure-out how create "robot" objects and then set them loose in a simulated world.Let's say the "world" is 10 squares wide by 10 squares wide.  If I use a 2D array to store the "world" and there are 2 "robot" objects in the world, then I have to process 98 squares i don't care about everytime I want to update the world.  The benefit is I can use the world to tell the "robot" what is around it when it wants to know this information.However, if I store the robots in their own array of robots, then when I loop through the array I know I am processing ONLY "robots" but then it is much harder for the robots to know about the rest of the world around them.How do I get around this?There are many solutions.  Here are some:A) The robot may know it's position in coordinates.  The world is stored as an array.  Coordinates are used to locate anything.B) The robot may know have a pointer to the cell it occupies. The world is stored as a graph instead of an array.  Each square has pointers to its neighbors.