Q207. Convert the following logic into a set of step-by-step instructions in a manner that uses stepwise refinement.

To execute coordination we proceed as follows. Each agent will consider in turn its north, east, south, and west neighbors. First the agent determines whether interaction will take place at all based on similarity. Then, if they do interact, they flip a coin to decide who is the leader and who is the follower. Then the follower copies the traits of the leader. And then onto the next neighbor if there is one.

We can incorporate the following design decisions into our model: (1) neighbors who have already interacted in a given round do not do so again; (2) an agent can change multiple times during a given round; (3) all interactions are with the agent's current state.