Beispiel #1
0
void simulationRun(void)
{
	CALbyte again;

	//simulation main loop
	mbusuSimulation->step++;
	
    //exectutes the global transition function, the steering function and check for the stop condition.
	again = calRunCAStep3D(mbusuSimulation);

	//check for the stop condition
	if (!again)
	{
		//breaking the simulation
		end_time = time(NULL);
		glutIdleFunc(NULL);
		printf("\n");
		printf("Simulation terminated\n");
		printf("Elapsed time: %ds\n", end_time - start_time); 

		//graphic rendering
		printf("step: %d; \tactive cells: %d\r", mbusuSimulation->step, mbusuSimulation->ca3D->A.size_current);
		glutPostRedisplay();
		return;
	}

#ifdef VERBOSE
	//graphic rendering
	printf("step: %d; \tactive cells: %d\r", mbusuSimulation->step, mbusuSimulation->ca3D->A.size_current);
	if (mbusuSimulation->step % REFRESH == 0)
		glutPostRedisplay();
#endif
}
Beispiel #2
0
void calglUpdate3D(struct CALGLRun3D* calglRun){
	if (calglRun->active){
		if (calglRun->firstRun){
			calglRun->firstRun = CAL_FALSE;
			calglRun->start_time = time (NULL);
			if (calglRun->calRun->init)
				calRunInitSimulation3D (calglRun->calRun);
		}
		//simulation main loop
		calglRun->step=calglRun->calRun->step++;
		//exectutes the global transition function, the steering function and check for the stop condition.
		calglRun->terminated = calRunCAStep3D(calglRun->calRun);
		//graphic rendering
		//#ifdef WIN32
		//		system("cls");
		//#else
		//		system("clear");
		//#endif
		//		printf("*----------------  Cellular Automata  ----------------*\n");
		//		printf(" Rows: %d, Columns: %d\n", calglGetGlobalSettings()->rows, calglGetGlobalSettings()->columns);
		//		printf(" Current Step: %d/%d; Active cells: %d\n", calglRun->calRun->step, calglGetGlobalSettings()->step, calglRun->calRun->ca3D->A.size_current);
		
        printf ("Cellular Automata: Current Step: %d/%d;", calglRun->calRun->step, calglRun->calRun->final_step);
		if(calglRun->calRun->ca3D->A)		
			printf("Active cells: %d\r", calglRun->calRun->ca3D->A->size_current);
		else
			printf("\r");
//		printf("*-----------------------------------------------------*\n");
		//check for the stop condition
		if (!calglRun->terminated)
		{
			calglRun->active = CAL_FALSE;
			//breaking the simulation
			calglRun->end_time = time(NULL);
			printf("\nSimulation terminated\n");
			printf(" Elapsed time: %d\n", (int)(calglRun->end_time - calglRun->start_time));
			printf("*-----------------------------------------------------*\n");
			//saving configuration
			//calglSaveStateUpdater3D(calglRun);
		}
	}
}