system
Given the following post, respond as if you're commenting on Reddit:
human
How are complex instinctual behaviors (like how beavers know how to build dams) encoded into DNA?

It seems like many animal behaviors (mating rituals, beavers/birds building nest, ants creating colonies etc) would be things that are so complex that they would have to be  learned through example or observation, and yet somehow most of these skills are hardwired into their DNA. 

I don't understand how DNA, which I think of as the blueprints for the physical construction of living things, can also contain such incredibly specific behavioral routines. I hope I am explaining this question clearly, because I would be fascinated to hear the answer. Thanks in advance!
gpt
Well, it's not 100% of the mechanics behind dam construction, but a major component appears to be that beavers have a compulsion to pile sticks on the sound of flowing water until they can't hear it any more.  If you stick a speaker playing the sounds of running water in the middle of a field, they will pile sticks on it.  

In practice, this results in beaverdams.  Water in a stream is noisiest at the shallow riffles.  Beavers pile sticks on this point.  water gets channeled around.  Beavers pile sticks on that, and so on until there's a full dam with water just seeping through.

Now, there's good evidence that more than just this goes into dam building, because beavers do some more advanced engineering tricks if needed....but it does go to show that complex behaviors can originate from relatively simple underlying causes.  In most cases there's not a hardwired "final plan" there's just a series of a few "if X, do Y" instructions that result in the final product.