Design for a brain: The origin of adaptive behavior