Animal ai that wonder around an area

Hi, I am new with learning Unity and my aim is to make a survival game.

The problem is, I have no idea on how to make an animal such as a pig to wonder around an area
and when the character gets too close it will flee.Or even instead of fleeing for another type of animal such as a deer, it will try to attack, could anyone help me with the building blocks towards to how to go about this.

It would be much appreciated.

Look under wander!