Hi all. Hope everyone is staying safe with this virus running around. I had a few hours on my hands this week so I thought it would be good to develop a model that simulates an infection in a group of moving people. Its a fun little model that allows you to play with different infection rates in a population and shows a dynamic chart of the infection spreading. Sorry for the morbid topic but it seemed relevant this week. One of the things I've been watching on the news was the desire to reduce the peak and this is being done by way of social isolation so I wanted to see if this model could replicate the flattening of the peak. It does and you might be interested to play with the model but I still have a coding issue and it is this.
I want to see the chart moving so I need to leave screenupdating on but that alone wasn't enough to allow the chart to update so I had to add a doevent line but one line wasn't enough I had to put it in twice!!. As you can see from the code below I've been trying different ways to get the screen updating. Its working now with the present code but only with the double DoEvent. Why do I have to run this line of code twice???
If anyone is interested in playing with the model I think its a bit of fun.
There are three variables to set, the number of time intervals a person remains sick after catching the virus, the speed at which people move around the space and the distance between people before the virus is transferred. The model starts off with 199 uninfected people (blue dots) and 1 infected person (red dot). they are all set on a particular direction at the beginning of the model. The infected person remains infected for the number of time periods set before being cured. NO ONE DIES AND ALL DOTS ARE EVENTUALLY CURED. If an infected person comes into contact (with in the set distance) of an uninfected person then the uninfected person becomes infected too. Once cured a person can not catch the virus again. Play with it by setting different variables in the three yellow cells and running the simulation button.
BUT PLEASE EXPLAIN WHY I NEED TWO DOEVENTS!!
Please Login or Register to view this content.
Bookmarks