As autonomous underwater vehicles (AUVs) merely adopt the inductive obstacle avoidance mechanism to avoid collisions with underwater obstacles, path planners for underwater robots should consider the poor search efficiency and inadequate collision-avoidance ability. To overcome these problems, a specific two-player path planner based on an improved algorithm is designed. First, by combing the artificial attractive field (AAF) of artificial potential field (APF) approach with the random rapidly exploring tree (RRT) algorithm, an improved AAF-RRT algorithm with a changing attractive force proportional to the Euler distance between the point to be extended and the goal point is proposed. Second, a two-layer path planner is designed with path smoothing, which combines global planning and local planning. Finally, as verified by the simulations, the improved AAF-RRT algorithm has the strongest searching ability and the ability to cross the narrow passage among the studied three algorithms, which are the basic RRT algorithm, the common AAF-RRT algorithm, and the improved AAF-RRT algorithm. Moreover, the two-layer path planner can plan a global and optimal path for AUVs if a sudden obstacle is added to the simulation environment.