Turtle Brawl

Everyone knows yellow turtles hate green ones and vice-versa. Putting them in a pond together is a recipe for a rumble:

This model customizes BAM2, the framework for interacting turtles. In this case turtles interact by fighting if their colors are different.

to interact [candidate]
  ;spill some blood:
  ask patches in-radius vision [set pcolor red]
  ; make some noise
  beep
  let my-blow random energy
  let candidate-blow random [energy] of candidate
  dec-energy candidate-blow
  ask candidate [dec-energy my-blow]
  ;clean up the blood
  ask patches in-radius vision [set pcolor black]
end

Where:

to-report qualified?
  report color != [color] of myself
end

Note: This is equivalent to:

to-report qualified?
  report [color] of self != [color] of myself
end

Here's the code:

brawl.nlogo