Port robot movement problem to C++.