Exploration of the cognitive systems underlying human friendship will be advanced by identifying the biological functions these systems perform. Here I propose that human friendship results from cognitive mechanisms designed to assemble support groups for potential conflicts. I draw on game theory to identify computations about friends that can increase performance in multi-agent conflicts. This analysis suggests that people would benefit from: 1) ranking friends, 2) hiding their friend-ranking,and 3) ranking friends according to their own position in partners' rankings. These possible tactics motivate the hypotheses that people possess egocentric and allocentric representations of the social world, that people are motivated to conceal this information, and that egocentric friend-ranking is determined by allocentric representations of partners' friend-rankings (more than others' traits). I report several investigations designed to test predictions derived from these hypotheses. The results suggest that the alliance hypothesis merits further attention as a candidate explanation for human friendship.