While human emotions are often associated with surges in hormones and other neuropeptides, emotions in machines might be associated with abstract states associated with progress (or lack of progress) in autonomous learning systems. In this view, affective emotional states correspond to time-derivatives (perturbations) in the learning curve of an arbitrary learning system.
Marvin Minsky, one of the pioneering computer scientists in artificial intelligence, relates emotions to the broader issues of machine intelligence stating in The Emotion Machine that emotion is "not especially different from the processes that we call 'thinking.'"
Minsky argues that emotions are different ways to think that our mind uses to increase our intelligence. He challenges the distinction between emotions and other kinds of thinking. His main argument is that emotions are "ways to think" for different "problem types" that exist in the world. The brain has rule-based mechanism (selectors) that turns on emotions to deal with various problems.
Image: Fearful face recognition after placebo infusion versus neutral face recognition after placebo infusion. WOEXP: 475. http://neuro.imm.dtu.dk/services/jerne/brede/WOEXP_475.html