Artificial neural network learning through pain and pleasure