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


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

本文整理汇总了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();
 }
开发者ID:phlipsi,项目名称:sudoku,代码行数:84,代码来源:fullhouse.cpp


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