| 171 | |
| 172 | '' Leader Selection '' |
| 173 | |
| 174 | {{{ |
| 175 | 0. each population has an id associated and a variable "master" initially equal with its id |
| 176 | 1. each population broadcasts its id to the others |
| 177 | 2. each population waits for the others' ids and computes the candidate master |
| 178 | 2.1. if the received id < "master" |
| 179 | 2.1.2 then "master" = the received id |
| 180 | 3. each population broadcasts its candidate master |
| 181 | 4. each population waits for the others' candidate masters and computes the real master |
| 182 | 4.1. if the received candidate master < my candidate master |
| 183 | 4.1.2 then my candidate master is updated |
| 184 | 5. each population knows the id of the master |
| 185 | |
| 186 | }}} |
| 187 | |