Project 2 for MA132
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

55 lines
1.2 KiB

#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include "rand.h"
#include "bugage.h"
#include "timing.h"
// Many variables have been omitted; this is just to get a minimal (dysfuncitonal) model working.
int main(int argc, char** argv)
{
if (argc != 2)
{
fprintf(stderr, "No initial population\n");
return 1;
}
BugArray = malloc(ADULTS * sizeof(int));
BugArray[ADULTS - 1] = atoi(argv[1]);
eggCount = 0;
FILE *dataout = fopen("data/newdata.dat", "w");
if (dataout == NULL)
{
fprintf(stderr, "Could not open data file for writing\n");
return 1;
}
for (int day = 0; day < 3650; day++)
{
fprintf(dataout, "%i, %d, %d\n", day, BugArray[ADULTS - 1], eggCount);
int deathCount = 0;
eggCount = 0;
for (int adult = 0; adult < BugArray[ADULTS - 1]; adult++)
{
if (adult % 2)
{
if(prngd() < mating_chance(day))
{
eggCount += bound_int((int) umremap(prngdn(), 28, 2), 0 , 40);
}
}
if(prngd() < death_chance(day))
{
deathCount += 1;
}
}
BugArray[ADULTS] -= deathCount;
BugArrayTick();
}
fclose(dataout);
}