Learning capabilities enhanced in harsh environments: a common garden approach