rewrote AStarPath based on quio's javascript implementation, PathFinding.js

and gave Direction more use-cases