#include <iostream>
#include <cmath>
#include <climits>
using namespace std;

struct person {
	int infected;
	int contageous;
	int alive;
	int suceptible;
	double x;
	double y;
	double vx;
	double vy;
};

void print_pop(person population[], int pos, int vel);
void change_array(person population[]);
void init_population(person population[]);
void move_pop(person population[]);
void calculate(person population[]);

const int TRUE = 1;
const int FALSE = 0;
const int POP_SIZE = 2;
int main()
{
	// initialize our population
	person population[POP_SIZE];

	init_population(population);
	print_pop(population, 1, 1);
	calculate(population);

	return 0;
}

void init_population(person population[])
{
	int i;
	
	// initialize SEIR variables
	for (i = 0; i < POP_SIZE; ++i){
		population[i].infected = FALSE;
		population[i].contageous = FALSE;
		population[i].alive = TRUE;
		population[i].suceptible = TRUE;
	}

	// initialize position of people
	for (i = 0; i < POP_SIZE; ++i){
		population[i].x = 100*((double)rand() / RAND_MAX);
		population[i].y = 100*((double)rand() / RAND_MAX);
	}

	// initialize their velocities
	for (i = 0; i < POP_SIZE; ++i){
		population[i].vx = (double)rand() / RAND_MAX;
		population[i].vy = (double)rand() / RAND_MAX;
	}

}

void print_pop(person population[], int pos, int vel)
{
	int i;

	if (pos){       // print positions
		for (i = 0; i < POP_SIZE; ++i){
			cout << "Population[" << i << "].x = " << population[i].x << "  ";
			cout << "Population[" << i << "].y = " << population[i].y << "\n";
		}
	}

	if (vel){       // print velocities
		for (i = 0; i < POP_SIZE; ++i){
			cout << "Population[" << i << "].vx = " << population[i].vx << "  ";
			cout << "Population[" << i << "].vy = " << population[i].vy << "\n";
		}
	}
	cout << "-------------------------------------------------\n";
}

void change_array(person population[])
{
	int i;

	for ( i = 0; i < POP_SIZE; ++i){
		population[i].x += 100;
		population[i].y += 100;
	}
	print_pop(population, 1, 1);	

}

void move_pop(person population[])
{
	int i;

	// assume timestep is = 1
	for (i = 0; i < POP_SIZE ; ++i){
		population[i].x = population[i].x + population[i].vx;
		population[i].y = population[i].y + population[i].vy;
	}

}

void calculate(person population[])
{
	int random_number, germ_passed;
	double distance;
	double prob_of_germ_pass;
	int i=0;

	// find the distance between the members
	distance = sqrt(pow(population[i].x - population[i+1].x, 2) + pow(population[i].y - population[i+1].y, 2));
	cout << "distance = " << distance << "\n";

	// find the probability that a germ is passed
	prob_of_germ_pass = 1 -.01*distance;
	if (prob_of_germ_pass < 0){
		prob_of_germ_pass = 0;
	}
	// is a germ passed?

	random_number = (double)rand() / RAND_MAX;
	if (random_number < prob_of_germ_pass){
		germ_passed = TRUE;
	}else{	
		germ_passed = FALSE;
	}

	// find probability that the germ causes the disease
	if (germ_passed){
		if ( (double)rand() / RAND_MAX > .5 ){
			// germ causes disease
		}
	}


}