With the rise of autonomous vehicles, researchers at the Institute of Cognitive Science at the University of Osnabrück have been working on a formula that can help a vehicle make a life or death decision when it is on the road.
Professor Peter Konig, a senior author of the paper, said: "Now that we know how to implement human ethical decisions into machines we, as a society, are still left with a double dilemma.
"Firstly, we have to decide whether moral values should be included in guidelines for machine behaviour. Secondly, if they are, should machines act just like humans?"
The research team used virtual reality to simulate a person driving a car and assessing how that person dealt with life or death decisions, such as responding to an obstacle or a person or animal on the road.
Writing about the study in the Frontiers in Behavioral Neuroscience journal, they said: "Self-driving cars are posing a new challenge to our ethics. By using algorithms to make decisions in situations where harming humans is possible, probable, or even unavoidable, a self-driving car's ethical behavior comes pre-defined.
"Ad hoc decisions are made in milliseconds, but can be based on extensive research and debates. The same algorithms are also likely to be used in millions of cars at a time, increasing the impact of any inherent biases, and increasing the importance of getting it right ...
"This study demonstrates the suitability of virtual reality for the assessment of ethical behavior in humans, delivering consistent results across subjects, while closely matching the experimental settings to the real world scenarios in question."