char s_file[MAX_CHARS];
char l_file[MAX_CHARS];
char r_file[MAX_CHARS];
+ x_txt[MAX_TXT];
+ y_txt[MAX_TXT];
+ z_txt[MAX_TXT];
+ status_txt[MAX_TXT];
+ conc_txt[MAX_TXT];
+ steps_txt[MAX_TXT];
+ cc_txt[MAX_TXT];
+ **arg_v;
d3_lattice d3_l;
max_x=X;
} else usage();
}
+ if(!strcmp(r_file,"")) rand_init(NULL);
+ else rand_init(r_file);
+ if(!strcmp(l_file,""))
+ {
+ i=max_x*max_y*max_z;
+ d3_lattice_init(&argc,argv,&d3_l,max_x,max_y,max_z);
+ if((d3_l->status=(unsigned char *)malloc(i*sizeof(unsigned char)))==NULL)
+ {
+ puts("failed allocating status buffer");
+ return -1;
+ }
+ memset(d3_l->status,0,i*sizeof(unsigned char));
+ if((d3_l->extra=(int *)malloc(i*sizeof(int)))==NULL)
+ {
+ puts("failed allocating concentration buffer");
+ return -1;
+ }
+ memset(d3_l->extra,0,i*sizeof(int));
+ } else
+ {
+ load_from_file(l_file,&d3_l);
+ d3_lattice_init(&argc,argv,&d3_l,d3_l->max_x,d3_l->max_y,d3_l->max_z);
+ }
+
+ d3_event_init(&d3_l);
+ if(!strcmp(l_file,""))
+ {
+ while((i<steps) && (quit==0) && (escape==0))
+ {
+ x_c=rand_get(d3_l->max_x);
+ y_c=rand_get(d3_l->max_y);
+ z_c=rand_get_lgp(d3_l->max_z,a_el,b_el);
+ distrib_c(&3d_l,cc,a_cd,b_cd);
+ process_cell(&3d_l,x_c,y_c,z_c,range,a_ap,b_ap,&cc);
+ if(i%refresh==0)
+ {
+ sprintf(x_txt,"x: %d",x);
+ sprintf(y_txt,"y: %d",y);
+ sprintf(z_txt,"z: %d",z);
+ sprintf(status_txt,"status: %c",(*(d3_l->status+x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y)&AMORPH)?'a':'c');
+ sprintf(conc_txt,"conc: %d",*(d3_l->extra+x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y));
+ sprintf(steps_txt,"step: %d",i);
+ sprintf(cc_txt,"total c: %d",cc);
+ arg_v[1]=x_txt;
+ arg_v[2]=y_txt;
+ arg_v[3]=z_txt;
+ arg_v[4]=NULL;
+ arg_v[5]=status_txt;
+ arg_v[6]=conc_txt;
+ arg_v[7]=NULL;
+ arg_v[8]=NULL;
+ arg_v[9]=steps_txt;
+ arg_v[10]=cc_txt;
+ d3_lattice_draw(&d3_l,x,y,z,10,arg_v);
+ scan_event(&d3_l,&x,&y,&z,&quit,&escape);
+ }
+ ++i;
+ }
+ }
+
+ while((quit==0) && (escape==0) && (nowait==0))
+ {
+ sprintf(x_txt,"x: %d",x);
+ sprintf(y_txt,"y: %d",y);
+ sprintf(z_txt,"z: %d",z);
+ sprintf(status_txt,"status: %c",(*(d3_l->status+x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y)&AMORPH)?'a':'c');
+ sprintf(conc_txt,"conc: %d",*(d3_l->extra+x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y));
+ strcpy(steps_txt,"step: end!");
+ sprintf(cc_txt,"total c: %d",cc);
+ arg_v[1]=x_txt;
+ arg_v[2]=y_txt;
+ arg_v[3]=z_txt;
+ arg_v[4]=NULL;
+ arg_v[5]=status_txt;
+ arg_v[6]=conc_txt;
+ arg_v[7]=NULL;
+ arg_v[8]=NULL;
+ arg_v[9]=steps_txt;
+ arg_v[10]=cc_txt;
+ d3_lattice_draw(&d3_l,x,y,z,10,arg_v);
+ scan_event(&d3_l,&x,&y,&z,&quit,&escape);
+ }
return 1;
}