Im going to say yes. But its not as simple as writing some source in c++. You have to deal with hardware, and other software that all interact with eachother. But they have been doing that stuff for a while now, especially in japan. Its on TV a lot about robots and what not.
What ur seeking for , is actually a whole different field of science called artificial intelligence .
Well ur imagination is possible but requires u to know a lot of concepts and knowledge on those specifics , hence its not a viable option if ur a newbie .