Tile Pathfinding

Ok, say, I have a 20x10 grid or whatever of squares.

And when I put up a wall, the units should know how to go around it.
I could make a maze, and they can find the way through it automatically (sorta like Desktop TD, and how the units move around any turret you place in its way :rocker: (handdrawngames.com) and advance to the center)

I can do everything related moving, I just need help developing a formula to allow them to path find their way to the center. My idea was to make them check if the grid infront of them is open, if it is, else check if the one above was, and go up 1, else, go down 1, else go up 2, else go down 2, and so on, and that check would manipulate the monster into going toward the other side, but if you want them to go toward a point, sorta like Desktop TD, a different formula would be needed. Any ideas?