Linear motor (LM) based shuttle cars will play an important role in the future transportation systems of marine terminals to cope with increasing container flows. These systems are known as agile port terminals because of their significant advantages. However, routing for multiple shuttle cars is still an open issue. We present a network model of a container yard and propose constrained dynamic programming (DP) for its routing strategy with collision avoidance. The algorithm is a modified version of typical DP which is used to find an optimal path for a single traveler. We evaluate the new algorithm through simulation results for three shuttle cars in a mesh-type container yard.