Imagine this scenario: Two patients need kidney transplants, and there’s only one donor organ available that both their bodies will accept. One is 60 years old but in good health, except for a bout with skin cancer that’s now in remission. The other is 30, but a heavy drinker — a risk factor for kidney recipients.

The question of which patient should get the kidney is a thorny one, laced with judgments about age and lifestyle. Currently, decisions like it are often made by committees of doctors who weigh many factors, from a patient’s age and medical outlook to the distance an organ would need to travel, in order to match a limited supply of donated organs with the long list of people waiting for a transplant. But a team of researchers at Duke and the University of Maryland have created an algorithm that attempts to reflect the ethical choices that a human would make based on responses to surveys about who should get the hypothetical kidney.

“We’re not advocating that AI replace human decision-making,” said Jana Schaich Borg, an assistant professor of social science at Duke who helped create the algorithm. “AI can inform and improve decision making. It helps unearth some of our biases, brings them out onto the table so that we can discuss them and be more reliable.”

To create the algorithm, the researchers first asked respondents on crowdsourcing marketplace Mechanical Turk which attributes they thought were acceptable to evaluate in prioritizing patients for organ donation. This ruled out certain categories — most respondents, for instance, agreed that it was inappropriate to consider a patient’s race, and there was enough dissent over whether it was appropriate to consider living dependents that the researchers decided to ignore it for the time being. Based on those responses, they decided to look at three factors loaded with baggage about lifestyle and remaining life expectancy: age, drinking habits, and history with cancer.

The decisions can be grim, but the researchers point out that panels of human experts currently do the same thing.

Then they peppered a second set of nearly 300 Mechanical Turk respondents with hypothetical pairs of patients — one young and a frequent drinker, for instance, versus another who was old but in good health — and asked which should receive a kidney.

Using that data, the team created an algorithm which, presented with two patients, decides which deserves the kidney using the weights from the Mechanical Turk respondents. True to its inputs, the algorithm favors young occasional drinkers who haven’t had a brush with cancer. The flip side of those decisions — that it waitlists older, sicker patients — can be grim, but the researchers point out that panels of human experts currently do the same thing. And according to Walter Sinnott-Armstrong, a philosopher who studies ethics at Duke and who contributed to the project, it’s a line of work that also provides valuable insight into ethical decisions that people can’t quite explain.

“With enough subjects, you can get much more information about how they’re weighing those things,” Sinnott-Armstrong said. “You can find out, for example, are they taking the fact that maybe it’s this person’s fault that they are in this situation because they drank so much? How does that weigh against the fact that they’re older, which is not their fault, or that they had skin cancer, which is not their fault?”

The idea of polling large groups of people about ethical questions and using their responses to train moral algorithms is a hot idea in artificial intelligence right now. Earlier this year, a team of researchers at MIT and Carnegie Mellon used a similar technique to create an AI that, given limited information about two people in a crosswalk, makes a snap moral judgment about which an autonomous car should run down if its brakes failed.

Like that research, the Duke algorithm is just a proof of concept. Still, it explores issues that are likely to gain an immediacy as the deployment of artificial intelligence systems becomes more widespread.

“I don’t think any of us are actually advocating for fully crowdsourcing the organ allocation process,” said John Dickerson, a computer scientist at the University of Maryland who helped develop the algorithm. “It’s more that we’ve just described a more principled method by which we can actually combine preferences.”

How organ recipients are matched with donors has long been a fraught topic. In 1987, during the early days of heart transplants, a pair of parents secured a transplant for their baby by making an emotional appeal on the television program “Donahue,” prompting concern among doctors.

Thirty years later, groups that facilitate organ donation have already started to deploy algorithms designed to make decisions as rapid and impartial as possible. Dickerson helped create the software behind a pilot program by the United Network for Organ Sharing, a U.S. nonprofit that generally facilitates organ transplants from deceased donors. The algorithm Dickerson worked on, though, looks at the more complex problem of assigning organs from living donors and matching them with recipients based on publicly-released weighted factors, like age, prognosis, and distance, which are decided by the organization’s expert committee. Similar programs already exist in the United Kingdom and the Netherlands.

As similar programs spread, Dickerson argues, it’s going to be important to decide what information the algorithms consider when deciding which lives will be prioritized.

“I had a hamburger the other day from McDonald’s, say,” Dickerson said. “Is that a bad lifestyle decision? Is that too bad to actually exclude me from the kidney exchange? Well, what if I had two hamburgers? What if I had ten hamburgers and a beer? What if I had ten hamburgers and four beers? Like, where do I draw that line? And that’s something that hopefully a methodology like this could also sort of suss out, and then incorporate into an algorithm in a principled way.”