Example #1
0
int main(int argc, char* argv[])
{
	afout.open("out.txt");
	wclock = new sf::Clock;

	bool record = true;
	bool init_selection = true;
	
	if (argc > 1)
	{
		if (strcmp(argv[1], "norecord")==0) record = false;
		else init_selection = false;
	}
	
	if (init_selection)
	{
		if (record) DeleteDirectory("arch");
		int ngenerations = 100;
		
		int ngs = 2;
		Genome** gs = new Genome*[ngs];
		gs[0] = readgenome("shipmind.mind");
		gs[1] = readgenome("shipmind2.mind");
		
		Population* pop = new Population(gs, ngs);

		for (int gen = 0; gen < ngenerations; gen++)
		{
			pop->calcfitness(evaluate);
			pop->printspecies();
			if (record) pop->savegeneration();
			pop->nextgen();
		}
		
		return 0;
	}
	
	else
	{
		Genome* g1 = readgenome(argv[1]);
		Genome* g2 = 0;
		if (argc > 2)
			g2 = readgenome(argv[2]);
		else
			g2 = readgenome("shipmind.mind");
		
		return openwindow(g1, g2);
	}
}