Illusions, delusions and self-learning