I've been working on a turn based tactics game on a grid. I've been trying to figure out how to store and relate the grid and the objects on it. Essentially, my question boils down to how to ask these two questions without violating the DRY(Don't Repeat Yourself) principle.
- Given a object, how to get it's position?
- Given a cell, how to find out what object is in it?
One particular thing I was thinking is that it doesn't make sense to talk about a object independently of the grid it is on. Therefore it seems like each object should have a reference to the grid. But having a grid doesn't make sense unless it has cells that contain objects. Is this just a place where things are tightly coupled enough that this kind of circular reference is acceptable?