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


C++ Coords::XCoord方法代码示例

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


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

示例1: SolveSquare

bool InCollectionSolver::SolveSquare(Coords coords)
{
  bool didSomething = false;
  Square * toSolve = _theBoard->GetSquare(coords);
  const vector<int> values = toSolve->Values();

  if (CheckIn(toSolve, _theBoard->GetCol(coords), coords.YCoord()))
  {
    _stats[ColToken]++;
    didSomething = true;
  }

  if (CheckIn(toSolve, _theBoard->GetRow(coords), coords.XCoord()))
  {
    _stats[RowToken]++;
    didSomething = true;
  }

  if (CheckIn(toSolve, _theBoard->GetArea(coords),
    _theBoard->IndexInAreaMap(coords)))
  {
    _stats[AreaToken]++;
    didSomething = true;
  }

  // Return whether we have managed to eliminate any possibilities
  return didSomething;
}
开发者ID:fkp,项目名称:src,代码行数:28,代码来源:inCollectionSolver.cpp

示例2: SolveSquare

bool UniqueInCollectionSolver::SolveSquare(Coords coords)
{
  bool madeProgress = false;
  Square * toSolve = _theBoard->GetSquare(coords);

  // For this solver, as we will solve the square as soon as we make progress
  // there is no point in checking any other collections as soon as one returns
  // true
  if (CheckForUniqueSolution(_theBoard->GetArea(coords), toSolve,
    _theBoard->IndexInAreaMap(coords)))
  {
    _stats[AreaToken]++;
    madeProgress = true;
  }

  if (!madeProgress && CheckForUniqueSolution (_theBoard->GetRow(coords),
    toSolve, coords.XCoord()))
  {
    _stats[RowToken]++;
    madeProgress = true;
  }

  if (!madeProgress && CheckForUniqueSolution(_theBoard->GetCol(coords),
    toSolve, coords.YCoord()))
  {
    _stats[ColToken]++;
    madeProgress = true;
  }

  return madeProgress;
}
开发者ID:fkp,项目名称:src,代码行数:31,代码来源:uniqueInCollectionSolver.cpp

示例3: GetAreaIdForCoords

// Make a mapping between some coordinates on the board an an integer
// representing the area it is part of. So for a 3x3 board this will
// look like:
//   000|111|222
//   000|111|222
//   000|111|222
//   -----------
//   333|444|555
//   333|444|555
//   333|444|555
//   -----------
//   666|777|888
//   666|777|888
//   666|777|888
//   
int Board::GetAreaIdForCoords(Coords coords)
{
  int areaSize = GetAreaSideSize();

  // Assumes we down fractions down when assigning to int
  int xComponent = coords.XCoord() / areaSize;
  int yComponent = coords.YCoord() / areaSize;

  return yComponent * areaSize + xComponent;
}
开发者ID:fkp,项目名称:src,代码行数:25,代码来源:board.cpp

示例4: IndexInAreaMap

int Board::IndexInAreaMap(Coords coords)
{
  // If we are using the boards area map, derive the index in the area
  // returned which signifies the square at the x/y coords. This assumes
  // that the squares in an area are populated by x coord, and then by
  // y.
  int areaSideSize = GetAreaSideSize();

  return coords.XCoord() % areaSideSize + (areaSideSize *
    (coords.YCoord() % areaSideSize));
}
开发者ID:fkp,项目名称:src,代码行数:11,代码来源:board.cpp

示例5: IsSquareValid

bool Board::IsSquareValid(Coords coords, int solvedValue)
{
  // Check that the solved value of this square doesn't appear in any of
  // the rows, columns or areas it belongs to as a solved value too
  if (ContainsSolvedValue(GetRow(coords), solvedValue, coords.XCoord()) ||
    ContainsSolvedValue(GetCol(coords), solvedValue, coords.YCoord()) ||
    ContainsSolvedValue(GetArea(coords), solvedValue, IndexInAreaMap(coords)))
  {
    cout << "Found invalid repeated value of " << solvedValue << endl;
    return false;
  }

  return true;
}
开发者ID:fkp,项目名称:src,代码行数:14,代码来源:board.cpp


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