本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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));
}
示例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;
}