The prospect of artificial intelligence (AI) has long been a source of knotty ethical questions. But the focus has often been on how we, the creators, can and should use advanced robots. What is missing from the discussion is the need to develop a set of ethics for the machines themselves, together with a means for machines to resolve ethical dilemmas as they arise. Only then can intelligent machines function autonomously, making ethical choices as they fulfill their tasks, without human intervention.