Evolving generalists in switching rugged landscapes