Learn about this topic in these articles:

work of Thorndike

…led to the theory of connectionism, which states that behavioral responses to specific stimuli are established through a process of trial and error that affects neural connections between the stimuli and the most satisfying responses.