From: Biomimicry of quorum sensing using bacterial lifecycle model
For (each loop or iter<iterMax) |
 // chemotaxis process |
 For (each bacterium ) |
  If (given probability >random) |
   Share information with surrounding neighbours |
   Tumble () |
   While (current function value Fc< previous function value Fp) |
     Swim (using Equation 2) |
   End While |
  Else |
   Share the information with two random-choice bacteria |
   Tumble (using Equation 2) |
   While (current function value Fc< previous function value Fp) |
     Swim (using Equation 2) |
    End While |
   End if |
  End For |
  // reproduction or elimination |
  If (reproduction conditions meet) |
    Sort and Split |
    Reproduction and elimination (using Equations 3 and 4) |
  End If |
  // migration |
  For (each bacterium) |
    If (a given probability Nmig > random) |
     Migrate to a new niche (using Equation 5) |
    End if |
  End For |
End For |