Say for instance you have a surface divided into squares and an object which is supposed to move through all these squares. Sum squares have obstacles which mean that the object cannot move through them. Don’t you know of any algorithm I can use so that the object can cover as much area and at the same time avoid the squares with obstacles?
I already have a class for creating the surface and a class for controlling the object.
You need to be a little clearer on your question. Did you really mean to say that it needs to cover the greatest area, or distance? (not the same thing) Is there a specific "destination" that the object is heading for, or is it just moving wherever it can to cover the most distance/area? Is this using a limited number of moves given a certain time span/"turns" for each move? How big is this surface, and how many obstacles are we talking about? (That will be necessary for someone to know if you need some some sort of branching recursive search algorithm, or whether a brute force calculation will suffice.) Also, note that it is unlikely that anyone will be able to help you with code that will work with your application without the slightest idea how it's implemented, so if you want more than general suggestions, you'll probably have to be a little more forthcoming with what you have so far.