I mentioned writing an epidemic simulator earlier, got it running. Not good enough for Sourceforge yet.
An epidemic simulation program. The screen X and Y resolution are read, then a pair of nested for loops iterate locations, for each there’s a random 10% chance that it’s populated. There’s an array of structs containing data about each populated cell/person. An important thing there is the X and Y location. Each loop through the array of structs I call a day. Every day each populated cell tries to move 1 location in a random direction if it can find an empty spot. At the start there’s one infected cell. There’s a 40% chance that if an uninfected cell contacts an infected one during the random moving around it becomes infected, after the 2 – 14 day incubation period. In the array of structs are counters like till_sick which if non-zero are decremented each day until they’re zero. Hitting zero changes the cell’s status in other ways. For tracking neighbors there’s a shadow [x][y] array which is indexed by the current location, what it contains is the index to the array of structs if inhabited, otherwise 0. So xy[100][100] might link to struct[33] and that’s what gets set to infected or not. And the x,y in the struct[33] are set to 100,100, each time one is updated they both get updated. An infected cell recovers after a random period, this tries to mimic covid-19.
There’s no quarantiinng happening, and cells don’t die either. I tried implementing quarantining but it was too absolute: everything just stopped. It’s easy enough to add a quarantined variable to the struct, but I need a leaky quarantine. Sort of like we have in the US where it’s voluntary so far. Written in C using Xlib. There’s one known bug then I’ll clean up the source and stick it on Sourceforge.
An epidemic simulation program. The screen X and Y resolution are read, then a pair of nested for loops iterate locations, for each there’s a random 10% chance that it’s populated. There’s an array of structs containing data about each populated cell/person. An important thing there is the X and Y location. Each loop through the array of structs I call a day. Every day each populated cell tries to move 1 location in a random direction if it can find an empty spot. At the start there’s one infected cell. There’s a 40% chance that if an uninfected cell contacts an infected one during the random moving around it becomes infected, after the 2 – 14 day incubation period. In the array of structs are counters like till_sick which if non-zero are decremented each day until they’re zero. Hitting zero changes the cell’s status in other ways. For tracking neighbors there’s a shadow [x][y] array which is indexed by the current location, what it contains is the index to the array of structs if inhabited, otherwise 0. So xy[100][100] might link to struct[33] and that’s what gets set to infected or not. And the x,y in the struct[33] are set to 100,100, each time one is updated they both get updated. An infected cell recovers after a random period, this tries to mimic covid-19.
There’s no quarantiinng happening, and cells don’t die either. I tried implementing quarantining but it was too absolute: everything just stopped. It’s easy enough to add a quarantined variable to the struct, but I need a leaky quarantine. Sort of like we have in the US where it’s voluntary so far. Written in C using Xlib. There’s one known bug then I’ll clean up the source and stick it on Sourceforge.