This simulation implements a proximity-based local interaction model of divide-the-cake, the simplest version of the Nash bargaining game.
Agents are initially assigned a random strategy, representing how many slices of cake they want. The strategies range between asking for nothing (0 pieces of cake) and asking for the entire cake (10 pieces). At the start of each round of play, individuals connect to all agents who are within a certain distance. They then play divide-the-cake with each of these agents. All interactions are pairwise, so don't confused this model with that of the proximity-based model discussed in chapter 7 of The Structural Evolution of Morality. That model considers an N-player variant of divide-the-cake.
After everyone has interacted, players use imitate-the-best to adopt a new strategy. If more than one strategy has earned the maximal score in an agent’ neighbourhood, the tie is broken by a coin toss.
Once all interactions and potential updating has been performed, agents move a little bit. The wandering is not exactly a random walk, as they change their heading less frequently than they move.