Pseudocode for the synchronous update (a) and the asynchronous update (b). For each time step t from 1 to the maximum simulation time T both algorithms update the position of each of the N particles, but how the three update steps (determine neighbours, update heading and update position) are carried out is different. With the synchronous update, each step is completed for all particles before the next step starts, whereas with the asynchronous update all three steps are carried out for one particle (i) before the first step is carried out for the next particle (i + 1). See electronic supplementary material, codeS2.m for the exact implementation of the asynchronous update (lines 53–92 and 148–152) and the synchronous update (lines 99–143).