本文整理汇总了C++中Sudoku::get_positions方法的典型用法代码示例。如果您正苦于以下问题:C++ Sudoku::get_positions方法的具体用法?C++ Sudoku::get_positions怎么用?C++ Sudoku::get_positions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sudoku
的用法示例。
在下文中一共展示了Sudoku::get_positions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: do_try_technique
Step FullHouse::do_try_technique(const Sudoku& sudoku) {
const Positions p = sudoku.get_positions(Cell::digit() == 0); // sudoku.get_not_fixed_positions();
for (int j = 0; j < 9; ++j) {
int row_count = 0;
int col_count = 0;
int box_count = 0;
for (int i = 0; i < 81; ++i) {
if (sudoku.get_digit(i) != 0) {
if (ROWS[j][i]) ++row_count;
if (COLS[j][i]) ++col_count;
if (BOXES[j][i]) ++box_count;
}
}
if (row_count == 8) {
const std::string vague_hint = "Full House";
const std::string hint = boost::str(boost::format("Full House in row %1%") % (j + 1));
Actions proposed_actions;
Pencilmarks already;
already.assign(true);
int where = -1;
for (int i = 0; i < 9; ++i) {
const int d = sudoku[9 * j + i].get_digit();
if (d != 0) {
already[d - 1] = false;
} else {
where = i;
}
}
assert(where != -1);
const int digit = first(already) + 1;
proposed_actions.push_back(boost::shared_ptr<Action>(new PlaceDigit(9 * j + where, digit)));
const int points = 4;
return Step(*this, vague_hint, hint, Step::EASY, proposed_actions, points);
}
if (col_count == 8) {
const std::string vague_hint = "Full House";
const std::string hint = boost::str(boost::format("Full House in column %1%") % (j + 1));
Actions proposed_actions;
Pencilmarks already;
already.assign(true);
int where = -1;
for (int i = 0; i < 9; ++i) {
const int d = sudoku[9 * i + j].get_digit();
if (d != 0) {
already[d - 1] = false;
} else {
where = i;
}
}
assert(where != -1);
const int digit = first(already) + 1;
proposed_actions.push_back(boost::shared_ptr<Action>(new PlaceDigit(9 * where + j, digit)));
const int points = 4;
return Step(*this, vague_hint, hint, Step::EASY, proposed_actions, points);
}
if (box_count == 8) {
const std::string vague_hint = "Full House";
const std::string hint = boost::str(boost::format("Full House in box %1%") % (j + 1));
Actions proposed_actions;
Pencilmarks already;
already.assign(true);
int where = -1;
for (int i = 0; i < 81; ++i) {
if (BOXES[j][i]) {
const int d = sudoku[i].get_digit();
if (d != 0) {
already[d - 1] = false;
} else {
where = i;
}
}
}
assert(where != -1);
const int digit = first(already) + 1;
proposed_actions.push_back(boost::shared_ptr<Action>(new PlaceDigit(where, digit)));
const int points = 4;
return Step(*this, vague_hint, hint, Step::EASY, proposed_actions, points);
}
}
return Step();
}