Quorum sensing is a cell-density-dependent gene regulation system that allows an entire population of bacterial cells to communicate in order to regulate the expression of certain or specific genes in a coordinated way depending on the size of the population. We present a model of the quorum sensing system in Vibrio fischeri using a variant of membrane systems called P systems. In this framework each bacterium and the environment are represented by membranes, and the rules are applied according to an extension of Gillespie's algorithm called the multicompartmental Gillespie's algorithm. This algorithm runs on more than one compartment and takes into account the disturbance produced when chemical substances diffuse from one compartment or region to another one. Our approach allows us to examine the individual behavior of each bacterium as an agent as well as the emergent behavior of the colony as a whole and the processes of swarming and recruitment. Our simulations show that at low cell densities bacteria remain dark, while at high cell densities some bacteria start to produce light and a recruitment process takes place that makes the whole colony of bacteria do so. Our computational modeling of quorum sensing could provide insights leading to new applications where multiple agents need to robustly and efficiently coordinate their collective behavior based only on very limited information about the local environment.