Several recent models have shown that altruism can spread in viscous populations, i.e. in spatially structured populations within which individuals interact only with their immediate neighbours and disperse only over short distances. I first confirm this result with an individual–based model of a viscous population, where an individual can vary its level of investment into a behaviour that is beneficial to its neighbours but costly to itself. Two distinct classes of individuals emerge: egoists with no or very little investment into altruism, and altruists with a high level of investment; intermediate levels of altruism are not maintained. I then extend the model to investigate the consequences of letting interaction and dispersal distances evolve along with altruism. Altruists maintain short distances, while the egoists respond to the spread of altruism by increasing their interaction and dispersal distances. This allows the egoistic individuals to be maintained in the population at a high frequency. Furthermore, the coevolution of investment into altruism and interaction distance can lead to a stable spatial pattern, where stripes of altruists (with local interactions) alternate with stripes of egoists (with far–reaching interactions). Perhaps most importantly, this approach shows that the ease with which altruism spreads in viscous populations is maintained despite countermeasures evolved by egoists.