Central-place foragers, such as social insects or nesting birds, repeatedly use the same routes from and to their nests when foraging for food. Such species forage more efficiently after accumulating experience. We examined, here, a relatively neglected aspect of such an improvement with experience—the avoidance of pitfall traps. Similar pits are built by antlions, which co-occur with the ants, but they also resemble other natural obstacles. We used the desert ant Cataglyphis niger, common in sandy habitats, and allowed it to forage for three successive runs for a food reward. Ant workers discovered food more slowly and in smaller numbers when pits were in their path. Pit presence also led to longer tracks by ants and slower movement. However, with experience, the ants fell into such pits less often and reached the food more quickly. To understand how past conditions affect current behavior, we investigated whether removing or adding pits led to a different result to that with a constant number of pits. Workers adjusted their behavior immediately when conditions changed. The only carryover effect was the longer tracks crossed by workers after pit removal, possibly resulting from the mismatch between the past and current conditions. Finally, the workers were more likely to fall into pits that were closer to the nest than those that were further away. This is a good example of the advantage that ambush predators can derive from ambushing their prey in specific locations.