Researchers have shown that machines are inching closer to self-learning, and perhaps even copping a little attitude.

Over at Google, a computer program using a database of movie scripts was asked again and again by researchers to define morality. It struggles to do so, and in a conversation recorded by its human engineers, becomes exasperated and ends the conversation by lashing out at its human inquisitor.

Here’s...