fixed #13, ai unit moved randomly after it reached it's first goal
also fixed calculation of distance by accounting for diagonal movement