How does a tree (or any plant, really), know to evolve to produce a delicious fruit or a poison berry, a seed inside an impenetrable shell, or invent a type of flying machine, in order to reproduce? (Each of these examples exists in my backyard)

How do they receive feedback about their evolutionary experiments? How do they know it worked/failed. [10]