He goes over building very simple machines that appear to have emotions, hopes, plans, etc., and goes over they exact topic you're talking about.
I think one book you may benefit from reading is http://www.amazon.com/Vehicles-Experiments-Psychology-Valent.... It's a wonderful and short book with some subtle humor and amazing powers of explanation. After reading it you may very well have a better understanding of how it's possible (and how many different ways it might be possible) for what we see as complex behaviors to emerge.
I've had dozens of friends read this short book, and they've all thanked me for the recommendation and ended up buying a copy for themselves.
https://www.amazon.com/Vehicles-Experiments-Psychology-Valen...