Fair or not, goats have not earned a reputation for their problem-solving abilities. Crows and chimpanzees are better known for deftly tackling new and unusual situations, like a snack that requires a tool to reach. But if you hide food in a strange cup and put a lid on it, a goat may find a way, a new study finds. And not just any goat, a team of researchers says. Animals that functioned like outsiders in their social group were best at tackling and solving a problem.

It can be difficult to study innovation in many animals, which psychologists define as solving new problems or solving old problems in new ways, said Álvaro Caicoya, a psychology graduate student at the University of Barcelona. Put something new and unusual nearby and a lot of species will flee; in the wild, “new and unusual” often means “deadly.” Many studies have focused on primates and birds, which can be less skittish, but these can only take us so far, Mr. Caicoya said.

“If we want to have a comprehensive idea of how cognition evolves,” he said, “we cannot always be testing the same species.”

So, cue the goats. And the oryxes, and the Barbary sheep, and the Przewalski’s horses, the giraffes, the dromedary camels and a variety of other hoofed mammals. Mr. Caicoya and his colleagues looked at 13 species of hoofed mammals, with their study totaling 111 individuals living in zoos in Spain and Germany.

They chose a variety of animals for a reason. Some of these animals have complex diets in the wild; some live in groups that break up and then re-form; and some are domesticated. All of these characteristics might affect their ability to think outside the box. Considering a mix of mammals meant that the researchers could see whether different lifestyles influenced the animals’ ability to solve a problem. For each species, the researchers chose a particularly irresistible food — carrots, alfalfa or another treat — and put them in lidded cups in their enclosures. Then the researchers waited to see what would happen.

In a study published on Wednesday in the Proceedings of the Royal Society B, Mr. Caicoya and his colleagues reported that around 38 percent of the animals avoided the cups entirely. Of those who approached a cup, 40 individuals managed to take the lids off to reach the food. Eighty-six percent of the dromedaries and 69 percent of the goats managed to get the goods. Living in a more complex social group or being domesticated — true of both camels and goats — were each linked to a greater willingness to take part in the task, although neither was a guarantee of success.

“I think this is a great way to understand the cognition that underlies a particular behavior across species,” said Joshua Plotnik, a comparative psychologist at Hunter College in Manhattan who was not involved in the study but reviewed the experiments’ design.

What was linked to success, as well as to willingness, was an individual animal’s social position. Close observation of the animals allowed the researchers to construct hierarchies of their social groups. They found that animals that were outcasts or low in the pecking order had less fear of new objects, more willingness to explore them and a greater chance of getting the prize.

It’s not clear whether these findings hold true in the wild — living in a zoo might encourage different behaviors than living on, say, the savanna. But there might be good reasons that those excluded from the group would be more open to trying new things.

“The ones that are on the margins of the groups are the ones that are eating less and have more problems surviving in nature,” Mr. Caicoya said speculatively, “so those are the ones that normally take more risks to get food.”

Necessity, perhaps, is the mother of innovation.