Scientists have developed a mathematical model for finding out what makes individuals nice or nasty.
They have designed a framework for examining social behaviour in a range of different species that will help advance the understanding of the evolution of sociality.
Dr Sasha Dall, from the University of Exeter, joined a team of international colleagues to explore why some individuals evolve to be genetically programmed to be nice, while others stay nasty.
The theory of kin selection has for some time allowed biologists to explain why some animals and other organisms adopt altruistic behaviour, at their own expense, for the benefit of their relatives - worker bees laying down their lives to promote the welfare of their mother, the queen, for example.
But up until now scientists have not been able to explain the role of genetic polymorphism - or why some individuals appear to be genetically programmed to help others whilst living side-by-side with others who tend to exploit their generosity.
Using colony-living microbes as inspiration to explore why some individuals are by nature generous and others less so, the researchers produced an innovative model of social evolution that allows them to understand how far this is likely to be influenced by conditioning or the surrounding environment.
They found the behaviour of individuals can often evolve to be determined by a set of inherited genetic tendencies that accurately predict social relationships, including their likely relatedness to other members of their community, and their surroundings rather than in direct response to what they sense or experience.
Dr Dall said: "As humans our behaviours are flexible and we base what we are meant to do on what we see after processing information about our world.
"However, some species rely on inherited instructions on what to do - individuals behave differently according to which specific genetic variants they are born with.
"What we have been able to show is how you can get a situation where you end up with distinct levels of genetically determined niceness coexisting within populations."
Professor Olof Leimar, of Stockholm University, was the lead author for the study.
"Social evolution theory hasn't previously addressed genetic polymorphism," he said.
"We have developed a model that allows us to explore this within a general framework alongside other behavioural influences.
"Our hope and aim is to do further work in this area to test our model experimentally."
:: The study, Genes as Cues of Relatedness and Social Evolution in Heterogeneous Environments, is published in the journal PLOS Computational Biology.