
The Mormon cricket will eat its own to gain nutriets such as salt and protein. The stronger crickets (they aren't really crickets, but that's the name) will resort to cannibalism to satisfy their needs but once the needs are satisfied they don't eat each other.
This is rather interesting because it reminds me of chess. That is, the idea of sacreficing a piece to gain a strategic advantage on your opponent. You may allow a knight, say, to be captured if that'll give you a better position to win the game. While you have lost a knight you may win the game. The price is worth it. Likewise the swarm may lose some members but the swarm itself survives.