The similarity discrimination effect occurs when a single gene or gene cluster causes its carriers to display both a variable phenotypic trait and a behavioural predisposition to cooperate preferentially with recognisably similar carriers. We distinguish this from the greenbeard effect, in which cooperation evolves through fixed phenotypic tags and genetically linked cooperative behaviour with others displaying the same tag. Our agent-based simulations show that the evolution of cooperation through similarity discrimination, in contrast to the greenbeard effect, does not depend on population viscosity or other restrictive conditions. Similarity discrimination evolves spontaneously in well mixed populations, not only in the Prisoner's Dilemma game but also across a range of different binary-choice strategic interactions, provided that agents can distinguish reliably between similar and dissimilar co-players.