Here’s something that may be of use to you at some particular time or place. Just type or paste text into the box below, and it’ll count out the number of characters, words, and lines.
|Characters: 0||Words: 0||Lines: 0|
|Time to read aloud: 0|
|Approx. number of printed pages: 0|
Hello, I saw your herd immunity simulator linked in a reddit thread, and I think I found a bug in it. Either that or I’m misunderstanding how it should work based on what you said in the accompanying Youtube video.
The infect() function is still calling itself when the cell itself is already infected. There is a a check to make sure that other cells aren’t infected before infecting them, but the problem is that the state of a cell can change *after* that check is made because of the execution order of the recursion.
Here’s the original reddit post which caught the bug. I replied to it.
Here are some updated versions of your original code. One adds a counter for each time that infect is called on a cell. The other has the counter plus adds another check for infected state (really the only one that you need).
If I’ve made a mistake or I’m improperly sharing your code, please let me know and I can modify it or take it down.