Robotics have helped improve human life in different aspects. The extensive use of domestic robots has increased in recent years. One of the technologies behind such development is robot navigation. Indoor robot-path planning in particular has been a complex issue due to the uncertainties of real-life dynamic environment. The proposed algorithm is based on dynamic programming (DP) for optimizing the traveling distance of a robot on the condition of obstacle- voiding. Maps with various terrains are constructed by the combination of potential functions, enhancing the flexibility in both static and dynamic environments. Dynamic Programming is then used to search for the optimized path in accordance to cost settings. The algorithm was first simulated in Matlab and later realized in an autonomous robot and wiimote localization system. The proposed method works as normal DP in a static environment, and outperforms traditional potential field under such conditions in terms of distance and efficiency. The algorithm also works in dynamic environment by the extensive use of its properties.