The semipalmated sandpipers arrive in their thousands and spend several weeks resting and mating on the shore, before leaving southern Canada for the warmer climes of South America.

Guy Beauchamp of the University of Montreal in Canada has been studying these birds for 10 years.

When they take to the skies, their flocks can be seen from a great distance. "We are talking about groups up to 100,000 birds," Beauchamp says.

Such a huge concentration of birds makes the sandpipers attractive targets to peregrine falcons. These birds of prey loiter nearby, waiting for the right moment to swoop in and attack. But several years ago, Beauchamp realised that the falcons were behaving oddly.

Instead of going in for the kill as soon as the sandpipers arrive, the falcons wait and attack them at seemingly random times.

Presumably the falcons are hungry, so Beauchamp wondered why they do not attack immediately.

It pays to be vigilant at times when an attack is most likely

Perhaps, he thought, they purposely delay their attacks so that the sandpipers would never know when to expect them?

To find out if this was true, he spent several weeks each year monitoring how long it took falcons to attack.

He also noted the locations and sizes of the sandpiper roosts, to see how cautious the sandpipers were and how they responded to attacks. It pays to be vigilant at times when an attack is most likely, but they cannot maintain this state for too long because they need to rest and sleep.

Beauchamp discovered that falcons often delayed their attacks. Occasionally they attacked as soon as the roost was settled, but sometimes they waited for more than an hour. This made it impossible for a sandpiper to predict when an attack was coming.

It's the predator manipulating the level of fear in their prey to increase their own success

This shows, says Beauchamp, that the falcons purposely keep the sandpipers guessing by being unpredictable.

"It's the predator manipulating the level of fear in their prey to increase their own success," he says. "It's good for the falcons to instil uncertainty in the minds of the pipers."

He has published his findings in the journal Behavioral Ecology and Sociobiology.

The sandpipers may also be manipulating the falcons right back, by being more reactive at certain times, suggests Beauchamp. "The prey can manipulate the uncertainly on the minds of the predators by being a bit erratic in their fear levels," he says.

Both are trying to outwit the other

They did this by occasionally leaving their roosting sites, even if they were not being attacked. A large group moving at speed makes them a hard target for falcons.

However, each time they did this they missed out on some much-needed rest. This suggests it was an active strategy to keep falcons at bay, Beauchamp says.

Effectively, the two birds are playing "some sort of game", says Beauchamp. "Both are trying to outwit the other."

We do not know whether these behaviours are conscious decisions, or a combination of learned and instinctive actions, admits Beauchamp.

What is clear is that the falcons are attacking in a way that "optimises their chances of a successful hunt" says Will Cresswell of the University of St Andrews in Scotland, UK, who was not involved with the work. But he says it is unclear whether falcons are actively manipulating the levels of fear in their prey.

"A predator waiting until their prey have relaxed or fallen asleep, because they have not seen a predator for a while, is just a sensible and somewhat inevitable hunting strategy for a surprise predator," says Cresswell.