Added utility function nextGridSpaceEdge to Train