Another important function of lists is managing execution of functions of the agents in a way that ensures an acceptable model of concurrency. In this simulation, when a cell burns, it sends messages to neighboring cells. Since its neighboring cells are likely to be burning as well, any cell will also need to be able to recieve and process messages from several neighbors as it sending its own messages out.
This was addressed in this simulation by splitting up the burn actions and the sending and processing of messages. When a cell is getting ready to ``do its thing'' (burn a bit), it needs to be sure that it has processed all the inputs that it is to recieve from its neigbhors. When it burns, it needs to make sure that its messages have been delivered to the relevant neighbors. To accomodate this, each cell is provided with a ``message cache'' (think of it as a mailbox). When the cell burns, it sends messages to some of its neighbors. Simultaneously, it will be recieving messages from its neighbors. Before its next time step, the cell will need to evaluate these messages and convert them to inputs for its own burn model.
By segregating the burn function of the cell into a doActions and a processMessages method3, the cellsurface can give a reasonable approximation of concurrency. In the doActions phase, the cellsurface first traverses the list of all its member cells, asking them to do their burn thing. As each cell burns, it sends messages to neighbors, which get stored in the message cache of each cell for future reference. During the processMessages phase, each cell is traversed again and the message caches are evaluated. Each cell evaluates its messages and decides on its inputs for its fire model(s) at the next burn step. Cells that have ``decided'' to ignite at this time step merely flag themselves as ignited, and wait for the next doActions phase to actually start burning. Only after this second traversal is complete, and every cell has processed its inputs, is the action phase permitted to start again. The cycle is illustrated in figures 4 and 5.
![]() |