A car is approaching a street crossing when its brakes fail. Three elderly pedestrians, a man and two women, are walking on a red signal. Inside the car are a man, a woman and a young girl.
What should the driver do? Continue ahead and likely kill the pedestrians, or steer into a concrete barrier and kill the passengers?
That is a difficult enough quandary, but what if the driver is a robot?
That is the world we are entering – autonomous cars of the future will need to make decisions in the case of emergencies.
And while brake failure like this will be almost unheard of, the algorithms to deal with such cases need to be written.
It is a reworking of the old "Trolley Problem", where a human has to decide by the flick of a rail switch who is killed by a runaway train car.
A study at the Massachusetts Institute of Technology is asking humans to assist machines to make the right decisions. During an online visit to the Moral Machine, you are presented with scenarios similar to that above and asked to play God. Who lives? Who dies? And how will machines make these decisions?
One of the scientists behind this experiment is Iyad Rahwan. He told Fairfax Media: "If we cannot engender trust in the new system, we risk the entire autonomous vehicle enterprise."
Driverless cars are already on the streets. In south Perth, a driverless bus is being trialled. The trial is limited and the vehicle will travel on a pre-programmed route. Driverless cars will be travelling on Melbourne's CityLink and Monash and Tullamarine freeways later this year. In these situations a driver will be sitting at the wheel, able to take over in a split second.
This situation will continue for some time, said Amnon Shashua, the founder of Israeli company Mobileye, which is developing technologies to enable fully autonomous vehicles. Professor Shashua was in Australia in November hosted by the Israel Trade Commission.
"It's not all going to be introduced in one day. You'll see self-driving cars with a human behind the steering wheel for a number of years until you can prove the fatality rate or accident rate has dropped by several orders of magnitude," he said.
Professor Shashua said academics should be looking at algorithms that deal with moral decisions, "but from the point of view of launching self-driving cars, this is a side issue".
"The big challenge in making decisions is trying to control a robotic car in a way that mimics human decision-making but on the other hand, should also be very safe."
Jean-Francois Bonnefon at the Toulouse School of Economics has been studying this matter with Iyad Rahwan at MIT. Professor Bonnefon said the car industry was working well to address safety. However, he said: "The car industry is not as well equipped to address this ethical dilemma, which leads them to the temptation to dismiss it as irrelevant.
"This position is untenable: people care about the ethical issues, and they need to see them addressed if they are to embrace self-driving cars."
Regulators are unlikely to ignore this matter. The US Department of Transport's recent policy release on automated vehicles says: "Manufacturers ... should address situations to ensure that ethical judgments and decisions are made consciously and intentionally."
While not referring to ethical considerations, the Australian National Transport Commission in November released its guidelines for automated vehicle trials.
The first recorded death caused by an autonomous vehicle occurred in May 2016. Joshua Brown, 40, from Ohio in the US, was killed when his Tesla vehicle hit a truck. One report said he was watching Harry Potter at the time. After the investigation, Tesla said "neither autopilot nor the driver noticed the white side of the tractor trailer against a brightly lit sky".
In December, Uber took its driverless cars off the streets of San Francisco when the city authorities said the company had been flouting local laws. (An Uber driver was in the vehicle at all times.) It followed reports that an Uber driverless car had gone through a red light.
The push, however, to bring driverless cars to our streets seems inevitable.
Professor Shashua and his company, Mobileye, say it will transform the way we live. He predicted that his company, with BMW and Intel, would have monitored driverless cars on the streets of Jerusalem and Munich by 2021.
"If you ask me whether autonomous vehicles will become commonplace, my unequivocal answer is 'Yes'; there's no question about it," he said. "The technology is almost there, the world is almost there, there's an economic motive for getting there, and drivers will slowly start to get used to the idea that you can get rid of the boring task of driving."
Projections suggest that the more autonomy machines have to drive cars, the fewer accidents and fatalities.
But technology will never be able reduce fatalities to zero. So how many deaths by robot can society accept?
In 2015, there were about 35,000 road fatalities in the US. Professor Shashua said robotic cars could reduce that number considerably.
"If you drop 35,000 fatalities down to 10,000 – even though from a rational point of view it sounds like a good thing, society will not live with that many people killed by a computer."
Even so, you don't have to show there will be zero accidents, as "this will never happen".
"What you need to show is that the probability of an accident drops by two to three orders of magnitude," he said. "If you drop [35,000 fatalities] down to 200, and those 200 are because of computer errors, then society will accept these robotic cars."
A similar proportional reduction in Australia would mean fewer than 10 deaths a year on the roads.
This dilemma is at the heart of the MIT research. In a paper, "The social dilemma of autonomous vehicles", Drs Bonnefon, Rahwan and their colleague Azim Shariff accept that autonomous vehicles will reduce fatalities.
However, they also point out that humans will want to wait until there is an acceptable threshold for death by robot. They write: "Regulating for utilitarian algorithms may paradoxically increase casualties by postponing the adoption of a safer technology."
"Most people want to live in in a world where cars will minimise casualties," said Dr Rahwan, an associate professor in the MIT Media Lab. "But everybody wants their own car to protect them at all costs."This is a big social dilemma. Who will buy a car that is programmed to kill them in some instances? Who will insure such a car?
This debate was fuelled further by a senior Mercedes-Benz executive in October. At the Paris Motor Show Christoph von Hugo, manager of driver assistance systems and active safety, said: "If you know you can save at least one person, at least save that one. Save the one in the car."
The MIT researchers say: "To align moral algorithms with human values, we must start a collective discussion about the ethics of autonomous vehicles."
For Professor Shashua, the vision is for cities where we won't have to drive ourselves. "We don't quite have the technology right now. We've seen Google attempts and Uber attempts, but they are very simplistic the way they negotiate traffic.
"But also we aren't looking for a scientific revolution – we just need the technological breakthrough. The science is there. It's just a matter of time to put the right resources and engineering together."
Dr Rahwan said the ethical issues could not be put to one side. "If people do not have a clear idea of how cars will behave, or how manufacturers will be accountable if the car misbehaves, then people may not buy those cars in the first place," he said. "Understanding those psychological barriers is crucial."
Just like people might give more weight to shark attacks than is rational, Dr Rahwan says people will overweigh safety "in their perception of autonomous cars".
"The psychological barriers cannot be set aside because they impact adoption, and because they may influence crucial design decisions we make today, both to the cars themselves as well as the regulatory environment."
The team behind the Moral Machine said: "As we are about to endow millions of vehicles with autonomy, taking algorithmic morality seriously has never been more urgent."