Social evolution depends critically on assortment, or segregation versus even mixing, between cooperators and noncooperators. Altruistic traits, which reduce the absolute fitness of their bearers, cannot evolve without positive assortment (excess segregation). The question of how positive assortment can arise has been controversial, but most evolutionary biologists believe that common descent is the only effective general mechanism. Here I investigate another recently proposed mechanism for generating nonrandom assortment, termed environmental feedback . This requires only that two forms of a trait affect the quality of the local environment differently in such a way that all individuals are more likely to leave low-quality locales. Experiments with simple computational models confirm that environmental feedback generates significant levels of genetic similarity among non-kin within locales. The mechanism is fairly general, and can under some conditions produce levels of genetic similarity comparable to those resulting from close genealogical relationship. Environmental feedback can also generate the negative assortment necessary for the evolution of spiteful traits. Environmental feedback is expected to create positive frequency-dependent selection, which thus favor any social trait that becomes common in the population. Results from this stylized model suggest that environmental feedback could be important in the evolution of both cooperation and spite, within as well as between species.