I am trying to create a simulation of a simple robot which moves about in a 2-D world using pygame. There are obstacles in the world. The robot only has contact sensors. So it can only sense something if it collides either with the boundaries of the world or the obstacles in it. So, collision detection is of utmost importance here.
I have two principal classes World and Robot. The World class contains information about the geometry of the world and also contains a list of Obstacles. The Robot class contains information about the Geometry of the robot and it's current position in the world. I believe, (but I am not sure ) that Robot should be contained in the World class since it is a part of the world. The Robot has methods to display itself and move which changes its position in the world. But for collision detection, I need information about the World such as its boundaries and the list of obstacles.
Now, I could make work my simple simulation by making the World class instance a member of the Robot class. This way, my robot gets information about the world and I happily do the collision detection. But, this doesn't make me happy.
Because, I might want to extend the simulation by having other robots in the world and things in the world which I don't want to expose to the robot (I am just experimenting with various AI algorithms here). In future, I might want to try out something wherein the robot has 0 knowledge of the world and it gains knowledge by exploring it.
If this were Java, I would have created an interface (say RobotWorldKnowledge) which the World class would implement and pass this to the Robot class. This interface would have selective knowledge of the world which the robot would use.
I don't know how to do this in python. I tried Googling "interfaces in python" but couldn't find a proper example. Most answers tell that interfaces are not necessary in python.
I might be wrong in what I assumed. Please help me out.
Thanks in advance
shahensha