"Ellie's movement and behavior is controlled by AI that adapts to player choice and performance. There are rule sets that look for how challenges play out as you play as Joel. So, if Joel engages enemies offensively, Ellie will follow. If Joel chooses stealth, Ellie will try to follow, with her motivations falling right in line with the player's. The game will track things like inventory, tendencies and other triggers to change Ellie's behavior dynamically, meaning that if Joel needs help, Ellie will probably try to help out. The goal was to make her feel like another human in the same situation, and you'll see her grow over the course of the game".
Guys, please visit that link!