The Physical Origin of Adaptation by Trial and Error