#include #include #include #include #include #include // #include // #include #define red "\x1b[31m" #define gre "\x1b[32m" #define res "\x1b[0m" #define bro " \e[0;33m" struct burningtree{ int x; int y; int status; }; int burnrate; int forest[25][25]; struct burningtree burning[625]; int burncount=0; struct burningtree *sort(struct burningtree tosort[], int size, bool asc){ int i; int issorted=0; int counter=0; while(issorted==0){ issorted=1; for (i=0;itosort[i+1].status){ struct burningtree temp=tosort[i]; tosort[i]=tosort[i+1]; tosort[i+1]=temp; issorted=0; } }else if(asc==false){ if(tosort[i].status80){ burning[i].status=-50; int x=burning[i].x; int y=burning[i].y; forest[x][y]=-1; burncount--; } } sort(burning,625,false); return 1; } int drawforest(void){ int i; int j; //Initialize a string for what will be outputted to the screen char output[100000]=""; //Initialize strings that will be concat'd to the main string char tree[]=gre " T"; char burn[]=red " B"; char dirt[]=bro "D"; char fizzled[]=res" F"; char newl[]=res "\n"; for(i=0;i<25;i++){ for(j=0;j<25;j++){ if(forest[i][j]==1){ strcat(output, tree); }else if(forest[i][j]==500){ strcat(output,burn); }else if(forest[i][j]==-1){ strcat(output,fizzled); } else{ strcat(output,dirt); } } strcat(output,newl); } printf("------------------------------------------\n"); printf("%s",output); fizzle(); return 1; } int spread(int size){ int i; int x; int y; #pragma omp for for(i=0;i0){ forest[x][y-1]=500; burning[burncount].x=x; burning[burncount].y=y-1; burncount++; }if(forest[x][y+1]==1&&random()%100