Governments are developing weapons that rely on artificial intelligence, not human instruction, to decide what to target and whom to kill.