Africa’s wildlife is in a constant state of danger.

Between 2009 and 2015, Tanzania and Mozambique lost more than half of their elephants, many of them to poaching for ivory smuggling. The decline has propelled African vulture populations, who feed on elephant carcasses, toward extinction too. And attempts at curtailing poaching and ivory smuggling haven’t helped the dwindling elephant population. In South Africa, rhinos are a prized poaching target too, for their horns. The attempts to keep poachers at bay having failed, some conservationists have proposed the expensive alternative of airlifting rhinos away from poaching sites.

Uganda, which remains “heavily implicated” in the illegal ivory trade according to the monitoring body CITES, is now testing a more direct way to crack down on the illegal hunters before they even get to the animals. Using Protection Assistant for Wildlife Security (PAWS), a technology combining machine learning and game theory, researchers can predict where poachers may attack and tell rangers where to patrol.

Elephant poaching Africa 2002-2014
Image: Guardian

“The basic idea is that you have limited resources, you can’t be everywhere all the time,” University of Southern California professor Milind Tambe, who’s leading the initiative, told Quartz. “Where and when should you do patrol?”

To make their predictions, researchers studied 12 years worth of data collected by rangers, from 2003 to 2015, provided by the Wildlife Conservation Society. These included reports of past attacks, snare placements, and other illegal activities. The data aren’t perfect, says Tambe: Rangers don’t patrol the entire park, so it’s hard to get a complete picture. But it’s enough to let a machine learning algorithm make intelligent guesses about where poachers will strike in future.

When creating patrol routes for rangers, “we want to randomize our patrols because we ourselves don’t want to become predictable to the poachers,” Tambe said. That’s where game theory comes in. It uses mathematical models to evaluate how rational human beings would act, to then suggest routes that won’t be easily predictable.

The US Coastguard, Transportation Security Administration (TSA), the Federal Air Marshals Service, LA Sheriff’s Department, and other organizations have been using Tambe’s AI-game theory combination technology to randomize their patrols since the early 2000s, he says. The concept was tailored for wildlife preservation in 2014 and deployed for testing in Malaysia in mid-2015. The current large-scale Ugandan tests in Queen Elizabeth National Park are backed by US organizations like the National Science Foundation and the Army Research Office.

Rangers using PAWS in Uganda have found 10 antelope traps and elephant snares in the past month, “a far better score card than they could usually expect,” Reuters reported. As robust as the technology might be in theory, factors like poor mobile internet connections can get in the way of communicating the results from PAWS that are used to direct rangers’ routes. And there’s another threat: Armed poachers are quick to point their guns at the rangers.