Updated AI algorithm

Smarter implementation of searching algorithm for AI path finding.
Introduced a more modular and cleaner traversal solution.