Books and movies have long been exploring the possibilities of artificial intelligence—usually with disastrous results