When nice guys finish first: a lesson from tiny robots

Meet Alice. She is 4 centimeters tall and moves about on wheels. Her goal in life is to look for food. Remarkably,the foraging behavior of this tiny robot has not been programmed by humans. Instead, her creators gave Alice a brain, and let evolution do the job of programming it. And Alice is going to show us why it is that individuals often make sacrifices for each other.

Animals often behave in seemingly selfless ways. The most regimented examples come from the social insects – the ants, termites, wasps and bees. Here selflessness is built in to the fabric of their society, as there are sterile castes of workers who tend to the eggs of the queen. Worker bees will often make the ultimate sacrifice and die protecting the hive from invaders. These are all altruistic acts, as they harm the individual while benefitting someone else.

A sweet deal? That's not a drop of honey, but in fact it's the engorged abdomen of the honeypot ant. These ants are used by the rest of the nest as living storage pots.

Take a moment to think about this behavior from the point of view of evolution. If everyone’s competing to get ahead, why take an unnecessary risk or suffer to help someone else? You really couldn’t do much worse than adopt a sterile lifestyle – it’s an evolutionary dead end.

People used to talk about such altruistic behavior as  being ‘for the good of the species’. But this explanation does not work. Natural selection does not operate at the level of species, it is solely concerned with the reproductive success of the individual. Any gene that inclines an individual to be more concerned with the welfare of the species than with their own welfare is not going to get very far.

This type of evolutionary logic paints a picture of a world red in tooth and claw, one where you need to constantly be watching your back. But if everyone is looking out for their own selfish interests, where does selflessness come from? The solution to this puzzle was put forward by J. B. S. Haldane in the 1930s, and made precise by William Hamilton in 1963. Hamilton had the remarkable insight to think of this as an economics problem, and rephrase it in terms of costs and benefits.

In the business of evolution, everyone is looking for the best strategy to invest their genes in the next generation. You are faced with two options. You can either 1. Be selfish and suffer no cost to yourself or 2. Be altruistic and help out a relative, while suffering a cost to yourself.

So what should you do? Well, if the relative is close enough and the benefit to them is sufficiently large, you should pick the latter option, because in helping them out you are helping out your own genes. This is known as kin selection. But if your kin is really a distant relative, and your suffering is not helping them much, then the selfish option is a better bet.

In other words, Hamilton realized that altruism is a more efficient way to propagate your genes than selfishness, provided that the benefit to your genes exceeds the cost that you suffer from the act. He summarized this strategy with the following simple equation:

Here r is the degree to which two individuals are related (1 for identical twins, 1/2 for siblings, 1/4 for nephews or nieces , 1/8  for cousins, and so on). B is the benefit that your kin will receive from your action. And C is the cost that you suffer by performing this act.

This is known as Hamilton’s rule, and when this equation is satisfied, it makes evolutionary sense to be selfless [1]. The biologist J. B. S. Haldane intuitively understood this concept. When asked if he would risk his life to save a drowning brother, he famously replied “No, but I would to save two brothers or eight cousins” [2].

Sterile worker bees. An un-intuitively good idea.

In the nests of ants, bees, and wasps (together known as the Hymenoptera) there is usually a single queen mother, and a sterile caste of daughters who are the workers that tend to her eggs. It turns out that through a quirk of their genetics, these female sisters are more closely related to each (r  = 3/4) other than they would be to their own offspring (r = 1/2). So as a savvy Hymenoptera female, the most effective way to propagate your genes is not to have any children of your own, but instead to get your mother to lay reproductively capable sisters for you. This is the origins of the sterile caste.

Now, of course, no one is saying that these insects are sitting down to calculate degrees of relatedness. Hamilton’s strategy is not being obeyed consciously. Richard Dawkins eloquently popularized the ideas of Hamilton and others in his brilliant book on the subject of altruism, The Selfish Gene. There he suggests the following analogy: you can think of an animal as a kind of unconscious robot following a specific program. The program was not written by any human programmer, instead it has been written and fine-tuned by natural selection. And after many rounds of being optimized by natural selection, you would expect to see selfishness or altruism emerge, in accordance with Hamilton’s rule.

In fact, why stop at an analogy?

In a recently published paper, Swiss researchers in engineering and in evolution collaborated to perform a neat experiment.

They built an arena for 8 Alice micro-robots, who were given the task of collecting food. The food in question was in the form of 8 tokens on the ground. Each robot could see the world with 6 sensors – 3 distance sensors to detect food, a fourth to distinguish food from other robots, and two vision sensors to know where to bring the food. They could get around using two wheels. And they had a software brain, known as a neural network.

Meet Alice. And meet her brain.

Neural networks are an attempt to emulate the ways in which the neurons in our brains are wired together. Think of it as a road map of Alice’s brain. Every neuron is depicted in the figure above as a grey circle, and it can either be on or off. If enough traffic flows into a neuron, it will switch on. On the left, the 6 input neurons respond to Alice’s every sensation. As they fire, they send traffic to the right. The 3 rightmost neurons are the output of her brain.

Alice is programmed by tuning the strengths of each of these neural corrections. You could think of them as speed limits on each of the different roads, which then determine how the traffic will flow. These 33 speed limits (one for each neural connection), taken together, completely determine how Alice will respond to any situation. They are her genome, the programming that makes her tick.

The robots used their brains to make a very important decision. Every time they collected a food item, they had to decide whether to be selfish or be altruistic. If they were selfish, they would rewarded by a certain amount (this is the cost C). If they were altruistic, they would forgo the reward, but instead benefit the other 7 robots (each of whom share the benefit B). So they are either feeding themselves of feeding the others. This decision is clearly a key factor in how much food each robot gets.

The experiment works as follows. Think of the 8 robots as a tribe. They are left in the arena to collect food. After one minute, the researchers count how much food each robot has collected, and tally up the costs and benefits. Those robots with the highest scores are the most successful, and their genes are then the most likely to make it into the next generation. They researchers also modeled two crucial features from biology – mutations and sex. The genomes could be slightly altered by random mutations at every generation, and they could shuffle with other genomes to produce hybrid offsprings (this is sex, with all the fun bits stripped away). In this way, the robot’s programming would change through small increments at every generation.

They repeated this game of artificial evolution for 500 generations [3]. At first, the randomly programmed robots spun about aimlessly, having no specific program or goal in mind. But over time, they started to get much better at collecting food. You can watch this happen in the following video interview with one of the authors (look out for the difference between generation 0 and generation 149):

The researchers repeated this experiment many times, while varying the values of the costs and benefits (C and B), and also varying the relatedness (r) of the robots in a tribe. There results of 500 generations are summarized in the figures below, taken from the paper.

This a plot of the number of food items they collected on average, at every generation. Each curve is a different tribe of robots. Initially, they all started off hopelessly ineffective at finding food. But over many generations, small mutations crept in to their mental program that made them slightly more effective. The individuals with these mutations had the most descendants in the next generation, and the process multiplied. Natural selection was, in effect, programming them to become better foragers. Within a 100 generations, you can see a dramatic improvement in their foraging ability.

But what about their behavior? That’s shown in the figure below.

The blue, yellow and red curves correspond to 3 different robot tribes. The blue tribes are those in which the overall benefit to genes exceeds the cost of being altruistic (rB >C). In the yellow tribe the cost and benefit to genes are matched (rB = C) and  in the red tribe, the cost exceeds the benefit to genes (rBthe robots evolve strategies of cooperation that agree precisely with Hamilton’s rule [4]. (According to the rule, the yellow tribe is exactly at the threshold for altruistic behavior, and indeed they are altruistic about half of the time.)

This work is interesting to me for a few reasons (not just because robots are inherently cool). It shows the incredible power of evolution to optimize strategies with no outside guidance. The robots were never taught how to forage, or when to be nice. But in surprisingly few generations, natural selection managed to wire them with an optimal strategy.

Hamilton’s rule has been notoriously difficult to test in the field, because it’s incredibly hard to quantify the costs and benefits of helping acts. The robot model certainly doesn’t come close to capturing the complexities of navigating the real world. But it does capture the essential features, and allows one to make precise quantitative tests of theoretical predictions of natural selection.

It’s a pleasing irony that by studying the behavior of tiny robots, we can learn more about the strategies of life.

References
Waibel M, Floreano D, & Keller L (2011). A Quantitative Test of Hamilton’s Rule for the Evolution of Altruism. PLoS biology, 9 (5) PMID: 21559320 Link

If you’re interested in learning more about the subject of altruism, these are some great books on the subject:

The Selfish Gene by Richard Dawkins

The Price of Altruism: George Price and the Search for the Origins of Kindness by Oren Harman

You may also enjoy this Radiolab episode on altruism, as well a few excellent documentaries that address the subject such as Nice guys finish last by Richard Dawkins (from where I borrowed the title of this post), or Life in the undergrowth by David Attenborough.

Photo Credit

The worker bees image is courtesy Todd Huffman, licensed under Creative Commons.

Footnotes

[1] This raises the dilemma that you’re not really being selfless, because you stand to gain in the long run. But I’ll leave this one for the philosophers.

[2] Hamilton’s equation is a nice embodiment of another classic Haldane quote – “An ounce of algebra is worth of a ton of verbal argument.”

[3] This would have been prohibitively time consuming to do with the real robots. Instead, much of this work was done using simulations on a computer model that could accurately capture the interactions of the robots.

[4] Even though they are complex enough to violate some of the assumptions of the rule.