Great article below about slime mold and its capacity to time its actions, navigate a maze, retain a record of where it's been, all of which happens without a nervous system.
So in my view an overarching template composed from the basic energetic principles of nature, organize its behavior to be in correspondence with local conditions. We shouldn't view the slime mold as an entity separate from its surroundings. External variables and processes of change are factored into its physiology and it evolves (rather than learns) to maintain its flow configuration in accord with the Constructal law. Complex behavior in dogs likewise reflects how the emotional climate they find themselves in, is factored out by their physiology as well as their neurology so that their behavior also evolves a flow configuration in accord with the Constructal law.