本文整理汇总了C++中Solver::SetCurPuzzle方法的典型用法代码示例。如果您正苦于以下问题:C++ Solver::SetCurPuzzle方法的具体用法?C++ Solver::SetCurPuzzle怎么用?C++ Solver::SetCurPuzzle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Solver
的用法示例。
在下文中一共展示了Solver::SetCurPuzzle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RecrussiveSolve
bool Solver::RecrussiveSolve()
{
//----------------------------------------
Solver::Count++;
//---------------------------------------
PriorityUnit Unit;
Solver solve;
#ifndef _GENERATOR_V1
int temp_pos, temp;
#else
int temp_pos;
int temp[9];
#endif // _GENERATOR_V1
int i;
int size;
CurPuzzle.reinitializepos();
while (CurPuzzle.Solve());
//-------------------------------------------------------------------------------
if (Solver::Count % 10000000 == 0)
{
for (int i = 0; i<9; ++i)
{
for (int j = 0; j<9; ++j)
{
std::cout << (*CurPuzzle.RetGrid())[i][j] << " ";
}
std::cout << "\n";
}
std::cout << "\n";
//system("pause");
}
//-------------------------------------------------------------------------------
if (CurPuzzle.FullPossibility()) return false;
//else
//std::cout << "got you!";
CurPuzzle.GeneratePossibilityCount();
CurPuzzle.GenerateInversePossibilityCount();
CurPuzzle.SetPossibilityCount();
Q = CurPuzzle.GenerateWaightValues();
if (CurPuzzle.IsSolved())
{
if (CurPuzzle.IsLegal() )
{
Solver::SudokuSolution = CurPuzzle;
Solver::IsSolutionSet = true;
return true;
}
else
return false;
}
solve.SetCurPuzzle(CurPuzzle);
//while (!Q.empty())
//{
Unit = Q.top();
temp_pos = (*CurPuzzle.RetPoss())[Unit.y][Unit.x];
//temp_pos = temp_pos & Solver::GlobalPossibilities[Unit.y][Unit.x];
size = Sudoku::NoOfElements(temp_pos);
#ifdef _GENERATOR_V1
int j, T;
for(i=0; i<size; ++i)
{
temp[i] = Sudoku::BitValue(temp_pos);
Sudoku::DeleteValue(temp[i], temp_pos);
}
srand(time(NULL));
for(i=0; i<size; ++i)
{
j = (rand() % size);
T = temp[j];
temp[j] = temp[i];
temp[i] = T;
}
#endif // _GENERATOR_V1
for (i = 0; i < size; ++i)
{
#ifndef _GENERATOR_V1
temp = (*solve.CurPuzzle.RetGrid())[Unit.y][Unit.x] = Sudoku::BitValue(temp_pos);
Sudoku::DeleteValue(temp, temp_pos);
#else // _GENERATOR_V1
(*solve.CurPuzzle.RetGrid())[Unit.y][Unit.x] = temp[i];
#endif
if (solve.RecrussiveSolve())
return true;
// it is obvious that 'false' is returned. So this value should not (never ever ever!!!) be
// checked again. Or else, we would be wasting a lot of time!!!!
//Sudoku::DeleteValue(temp, Solver::GlobalPossibilities[Unit.y][Unit.x]);
solve.SetCurPuzzle(CurPuzzle);
}
(*solve.CurPuzzle.RetGrid())[Unit.y][Unit.x] = 0;
Q.pop();
//}
return false;
}