Can anybody help me to end a simulation when there is no one inside? That is simulation could e开发者_如何学Pythonnd when the syatm gets empty
The easiest way to do so would be to keep track of the number of entities in your system, and check this number against 0 on every iteration.
A possible approach in an OO-language could be to derive all your entities from a common ancestor class. This should contain a static variable which is incremented in the constructor and decremented in the destructor of an entity.
精彩评论