I think there's more to it than that.
If it was just about resources like Elana said and just about being opportunistic like you say then why is it that Wally won't take the same treat he'd almost bite my hand off for when it's in the hands of someone he's never met?
It's all about opportunity and resources, right?
I agree completely with this. There are too many examples of pets forsaking physical needs for the affection of their owners. I once watched a crime show which was about the murder of a woman and her two dogs. The husband was the prime suspect but no one could figure out why he wouldn't have bite marks etc.
It turned out that he did murder both his wife's dogs (by beating the poor things to death

) and then his wife... but the dogs knew and loved him, so even though they were being beaten to death, they submitted.
I don't think anyone would deny that the natural instinctive reaction to being beaten to death would be to attack back! So how to you explain their not acting on this instinct other than that they knew and loved the man who was supposedly their caretaker? (No, they hadn't been drugged or restrained... forensics showed they had been awake and alert during the attack. BTW, the sicko at least had the conscience to put "his" dog safely away in the bedroom, and that dog was found unharmed.)
Also, what about empathy? I told someone one time about how Dixon senses when I'm having a bad day or am physically hurt and she will come and cuddle and give me kisses. That person told me, "Oh, that's only because they like the salty taste of tears."
Um, no, she's not kissing tears, she's kissing my hands and cheek... not to mention her whole demeanor is one of empathy (from the expression on her face to the way she wags her tail).
Also, if she's missing someone, she won't eat or drink until the person she's missing comes back. This afternoon, we took her for an outing to spend some quality time with her without the boys, and we had to run an errand on the way home. I stayed in the car with Dixon because it's a warm day and we needed to leave the air conditioning on for her. She was hot and very obviously thirsty, but she wouldn't drink from her bowl no matter how I tried to get her to drink some cool, fresh water... she kept her eyes fixed on the store entrance to watch for her Daddy to come out.
I kept trying to get her to drink (she REALLY needed some water) and she just had no interest. When my husband came back, I kept the water bowl up to her so she could drink, but she wouldn't take a sip until she had showered her Daddy with hugs and kisses first.
Now, we have never used NILIF with Dixon (because I hadn't heard of it until I joined this forum), so she's never been conditioned to have to give affection or wait or perform any behavior in order to get food. She didn't drink until she could give love to her Daddy by her
own choice, not because of anything she had learned.
How do you explain that if dogs are ultimately opportunistic?