Militaries around the world are designing artificial intelligence–powered weapons that could one day make their own decisions about who to target. The technology could change warfare, but at what cost?