update and create some functions
fix a bug that when search the map for move, it may return the unit
which is currently been dealing with.