开发者

End a simulation run when the system gets empty

开发者 https://www.devze.com 2023-01-12 05:17 出处:网络
Can anybody help me to end a simulation when there is no one inside? That is simulation could e开发者_如何学Pythonnd when the syatm gets emptyThe easiest way to do so would be to keep track of the num

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消