当前位置: 首页>>代码示例>>C++>>正文


C++ Sudoku::GetFitness方法代码示例

本文整理汇总了C++中Sudoku::GetFitness方法的典型用法代码示例。如果您正苦于以下问题:C++ Sudoku::GetFitness方法的具体用法?C++ Sudoku::GetFitness怎么用?C++ Sudoku::GetFitness使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sudoku的用法示例。


在下文中一共展示了Sudoku::GetFitness方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

/**
 * If no arguments are passed, try to search for launch file to run accordingly, otherwise blank sudoku with just hill climbing
 * otherwise one can pass '1' or 'file' followed by filename of the launch file to run this solver (See ReadMe)
 * or one can pass '2' or 'args' followed by arguments in the predefined order to run solver solver (See ReadMe)
 */
int main(int argCount, char** argValues)
{
	/** Initializing Variables with default values **/
	Sudoku sudoku;
	iterationCount = 0;
	temperature = 0;
	temperatureDropConstant = 0;
	temperatureDropIterations = 1;
	unsigned int seed = time(NULL);
	string filename;
	SimulationType  simType;

	//cout << argCount << endl;
	//checking input arguments
	if(argCount > 2)
	{
		string input = argValues[1];
		if(input[0] == '1' || input.compare("file") == 0 )
		{
			//cout<< "lq\n"<< input[1];
			ReadFromFile( argValues[2], filename, simType, seed );
			sudoku = Sudoku(filename, seed);
		}
		else if(input[0] == '2' || input.compare("args") == 0)
		{
			ReadFromArgs(argCount, argValues, filename, simType, seed);
			sudoku = Sudoku(filename, seed);
		}
		else
		{
			simType = HILL_CLIMBING;
		}
	}
	else
	{
		ifstream launchFileReader(launchFile);
		if(launchFileReader.is_open())
		{
			launchFileReader.close();
			ReadFromFile(launchFile, filename, simType, seed );
			//cout << filename << " - " << simType << endl;
			sudoku = Sudoku(filename, seed);
		}
		else
		{
			simType = HILL_CLIMBING;
		}
	}

	cout<<"Sudoku (from input file)"<<endl;
	sudoku.PrintSudoku();
	sudoku.calculateFitness();
	cout<<"Fitness = " << sudoku.GetFitness() << endl << endl << endl;

	cout<<"Sudoku (Initialized)"<<endl;
	sudoku.fillSudoku();
	sudoku.PrintSudoku();
	sudoku.calculateFitness();
	cout<<"Fitness = " << sudoku.GetFitness() << endl << endl << endl;

	//HillClimbing(sudoku, seed);
	//SimulatedAnnealing(sudoku, seed);

	switch (simType)
	{
		case (SIMULATED_ANNEALING): SimulatedAnnealing(sudoku,seed);
			break;
		case (HILL_CLIMBING_PROBABILITY): HillClimbingProbability(sudoku,seed);
			break;
		case (HILL_CLIMBING):
		default:
			HillClimbing(sudoku,seed);
	}



	return 0;
}
开发者ID:adarkhorse,项目名称:Sudoku_Solver,代码行数:83,代码来源:main.cpp


注:本文中的Sudoku::GetFitness方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。