wave algorithm for path finding