I would recommend to start reading about A* algorithm. It's one of the most commonly used pathfinding algorithms. For example, Wikipedia has a pretty good [article](http://en.wikipedia.org/wiki/A*_search_algorithm) on the topic, with an animated gif demonstrating the process.