Here is the list of variables and arrays used by the program. Note the naming scheme; variables whose names begin with “my” are private to the threads that use them. Variables whose names begin with “our” are private to the processes that use them, but public to the threads within that process. Variables are thus named from a thread’s perspective; “my” variables are ones that I use, “our” variables are ones that I and the other threads in my process use.
// Data being used for the X display
struct display_t {
#ifdef TEXT_DISPLAY
// Array of character arrays for text display
char **environment;
#endif
#ifdef X_DISPLAY
// Declare X-related variables
Display *display;
Window window;
int screen;
Atom delete_window;
GC gc;
XColor infected_color;
XColor immune_color;
XColor susceptible_color;
XColor dead_color;
Colormap colormap;
char *red;
char *green;
char *black;
char *white;
#endif
};
environment
2D array, holds an ASCII representation of the environment (see “state” under “Person” in the “Model” section). This variable is used only when we are using Text Display.
display
Display, display pointer for the connection to the X server
window
Window, variable to hold the window id.
screen
Screen, variable to hold default screen
delete_window
gc
infected_color
immune_color
susceptible_color
dead_color
red
array of char, holds value #FF0000, which is the hex code for color red.
green
array of char, holds value #00FF00, which is the hex code for color green.
black
array of char, holds value #000000, which is the hex code for color black.
white
array of char, holds value #FFFFFF, which is the hex code for color white.
colormap
// All the data needed globally. Holds EVERYONE's location,
// states and other necessary counters.
struct global_t
{
// current day
int current_day;
// people counters
int number_of_people;
int num_initially_infected;
// states counters
int num_infected;
int num_susceptible;
int num_immune;
int num_dead;
// locations
int *x_locations;
int *y_locations;
// infected people's locations
int *infected_x_locations;
int *infected_y_locations;
// state
char *states;
// infected time
int *num_days_infected;
};
current_day
a loop iterator representing the ID of the current day being simulated by the current process.
number_of_people
the total number of all people in the simulation. The value of this variable can be specified on the command line with the –n option.
num_initially_infected
the total number of people who are initially infected. The value of this variable can be specified on the command line with the –i option. This is a subset of the total number of people, so the value of this variable must be smaller or equal to the value for number_of_people.
num_infected
acount of the number of infected people. This value changes throughout the course of the simulation.
num_susceptible
acount of the number of susceptible people. This value changes throughout the course of the simulation.
our_num_immune
acount of the number of immune people. This value changes throughout the course of the simulation.
our_num_dead
acount of the number of dead people. This value changes throughout the course of the simulation.
x_locations
array, holds the x locations of all of the people; used if the environment needs to be displayed.
y_locations
array, holds the y locations of all of the people; used if the environment needs to be displayed.
infected_x_locations
array, used in susceptible() to keep track of the x locations of the infected people.
infected_y_locations
array, used in susceptible() to keep track of the y locations of the infected people.
states
array, holds the states of all of the people; used if the environment needs to be displayed.
num_days_infected
array, used to keep track of the number of days each person has been infected.
struct const_t
{
// environment
int environment_width;
int environment_height;
// disease
int infection_radius;
int duration_of_disease;
int contagiousness_factor;
int deadliness_factor;
// time
int total_number_of_days;
int microseconds_per_day;
};
environment_width
environment_width – indicates how wide the environment is; used to draw the environment and to make sure people stay within the bounds of the environment.
environment_height
environment_height – indicates how high the environment is; used to draw the environment and to make sure people stay within the bounds of the environment.
infection_radius
see the introduction chapter. The value of this variable can be specified on the command line with the –d option.
duration_of_disease
see the introduction chapter. The value of this variable can be specified on the command line with the –T option.
contagiousness_factor
see the introduction chapter. The value of this variable can be specified on the command line with the –c option.
deadliness_factor
see the introduction chapter. The value of this variable can be specified on the command line with the –D option.
total_number_of_days
the total number of days over which to run the simulation.
microseconds_per_day
used to tell how many microseconds to freeze in between frames of animation. The value of this variable can be specified on the command line with the –m option.
// Data being used for SHOW_RESULTS
struct stats_t
{
double num_infections;
double num_infection_attempts;
double num_deaths;
double num_recovery_attempts;
};
our_num_infections
used to count the number of actual infections that take place (in which an infected person transmits the disease to a susceptible person). Only used if the showing of results is enabled (i.e., if the program is to print out final results from the simulation). Used to determine the actual contagiousness of the disease, which can be compared to the contagiousness factor by the user.
our_num_infection_attempts
used to count the number of times a susceptible person is within an infection radius of an infected person, even if the infection fails. Only used if the showing of results is enabled (i.e., if the program is to print out final results from the simulation). Used to determine the actual contagiousness of the disease, which can be compared to the contagiousness factor by the user.
our_num_deaths
used to count the number of times a person dies. Only used if the showing of results is enabled (i.e., if the program is to print out final results from the simulation). Used to determine the actual deadliness of the disease, which can be compared to the deadliness factor by the user.
our_num_recovery_attempts
used to count the number of times an infected person is able to become immune. Only used if the showing of results is enabled (i.e., if the program is to print out final results from the simulation). Used to determine the actual deadliness of the disease, which can be compared to the deadliness factor by the user.