Hawk and Dove is a simulation of the Hawk-Dove game described by John Maynard Smith and George Price in their paper "The logic of animal conflict." Evolutionary game theory is fascinating. Here is one good book on the subject.
This simulation requires NumPy and PyGame. I wrote it as an exercise to practice object orientation. Instead of simulating each round of the game offscreen, birds bounce around in a Pong-like environment, playing a round of Hawk-Dove when they collide. Here are the controls:
-
[ h ]: Spawn a new hawk.
-
[ d ]: Spawn a new dove.
-
[ b ]: Spawn an new bourgeois.
-
[ p ]: Print population statistics to the terminal.
-
[ q ]: Kill all current birds.
-
[ = ]: Raise death threshold.
-
[ - ]: Reduce death threshold.
-
]: Raise replication threshold.
-
[ [ ]: Reduce replication threshold.
-
[ " ]: Raise game payoff.
-
[ ; ]: Reduce game payoff.
-
[ / ]: Raise game cost.
-
[ . ]: Reduce game cost.
-
[ l ]: Enable fitness-based speeds.
-
[ k ]: Disable fitness-based speeds.
-
[ up arrow ]: Increase game speed.
-
[ down arrow ]: Decrease game speed.
-
[ z ]: Print current death threshold, replication threshold, game cost, and payoff to the terminal.