Window width greater than height draw fix

A window with a width much greater than the height gave some drawing
issues. This is now fixed.
Path finding based on Dijkstra

The path finding is now based on a Dijkstra algorithm.