Humans and other walking bipeds often encounter and compensate for uneven terrain. They might, for example, regulate the body's momentum when stepping on stones to cross a stream. We examined what to do and how far to look, as a simple optimal control problem, where forward momentum is controlled to compensate for a step change in terrain height, and steady gait regained with no loss of time relative to nominal walking. We modeled planar, human-like walking with pendulum-like legs, and found the most economical control to be quite stereotypical. It starts by gaining momentum several footfalls ahead of an upward step, in anticipation of the momentum lost atop that step, and then ends with another speed-up to regain momentum thereafter. A similar pattern can be scaled to a variety of conditions, including both upward or downward steps, yet allow for considerably reduced overall energy and peak power demands, compared to compensation without anticipation. We define a "persistence time" metric from the transient decay response after a disturbance, to describe how momentum is retained between steps, and how far ahead a disturbance should be planned for. Anticipatory control of momentum can help to economically negotiate uneven terrain.