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


C++ Coords类代码示例

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


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

示例1: playMoves

/**
 * Play moves on move at a time
 */
void Board::playMoves() {
    std::list<Coords>::const_iterator iterator;
    bool allMovesGood = true;
    for (iterator = moves.begin(); iterator != moves.end(); ++iterator) {
        Coords move = *iterator;
        if (legalCoord(move)) {
            if (move.isStartMove()) {
                cmatrix[move.m_y][move.m_x].m_pointType = PointType::Start;
                currentMove = move;
                printBoardBasic();
                continue;
            } else if (move.isEndMove()) {
                cmatrix[move.m_y][move.m_x].m_pointType = PointType::End;
            } else {
                cmatrix[move.m_y][move.m_x].m_pointType = PointType::Normal;
            }
            if (!isValidMove(currentMove, move)) {
                allMovesGood = false;
                cout << "Move " << move << " is invalid" << endl;
            } else {
                cout << "Move " << move << " is valid" << endl;
            }
            currentMove = move;
            printBoardBasic();
        } else {
            allMovesGood = false;
            cout << "Move " << move << " is invalid" << endl;
        }
    }
    if (allMovesGood) {
        cout << "Summary: All moves are valid" << endl;
    } else {
        cout << "Summary: There are some invalid moves in the sequence" << endl;
    }
}
开发者ID:jonathanluo,项目名称:lang,代码行数:38,代码来源:board.cpp

示例2: 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

示例3: GetSeedPoints

Coords GetSeedPoints() {
    Coords seedPoints;
    for( int row = 0; row < 15; ++row ) {
        for( int col = 0; col < 15; ++col ) {
            int cell = row * 15 + col;
            if( !isalpha( board_state[cell] ) ) {
                int n = row * 15 + col;
                if( row > 0 ) n -= 15;
                int s = row * 15 + col;
                if( row < 14 ) s += 15;
                int e = row * 15 + col;
                if( col > 0 ) e -= 1;
                int w = row * 15 + col;
                if( col < 14 ) w += 1;
                bool ns = false;
                if( isalpha( board_state[n] ) || isalpha( board_state[s] ) )
                    ns = true;
                bool ew = false;
                if( isalpha( board_state[e] ) || isalpha( board_state[w] ) )
                    ew = true;
                if( ns || ew )
                    seedPoints.push_back( Coord( row, col ) );
            }
        }
    }
    if( seedPoints.empty() )
        seedPoints.push_back( Coord( 7, 7 ) );
    return seedPoints;
}
开发者ID:raspofabs,项目名称:wordfinder,代码行数:29,代码来源:test.cpp

示例4:

bool Coords::operator==(const Coords& c) const {
    double tol = 0.05;
    if (std::abs(c.getX() - this->getX()) < tol and std::abs(c.getY() - this->getY()) < tol) {
        return true;
    }
    return false;
}
开发者ID:ealiasannila,项目名称:lcpc,代码行数:7,代码来源:coords.cpp

示例5: coordsToIndex

    size_t Board::coordsToIndex(const Coords &c) const {
        if (!inRange(c)) {
            throw std::out_of_range("Passed coords are outside of board range.");
        }

        return dim.getX() * c.getX() + c.getY();
    }
开发者ID:markusj,项目名称:workshop-ss12-04,代码行数:7,代码来源:Board.cpp

示例6: 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

示例7: Coords

Coords ChunkManager::blockToChunkCoords(Coords in)
{
	int newX = std::floor((float)in.x() / (float)Chunk::chunkWidth);
	int newY = std::floor((float)in.y() / (float)Chunk::chunkWidth);
	int newZ = std::floor((float)in.z() / (float)Chunk::chunkHeight);
	Coords result = Coords(newX, newY, newZ);
	return result;
}
开发者ID:AditGame,项目名称:Adit,代码行数:8,代码来源:ChunkManager.cpp

示例8: 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

示例9: 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

示例10: 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

示例11: coords

void ChunkManager::setCenterChunk(Coords center, bool force)
{
	if (center == _center && !force) return;
	_center = center;
	//Delete out-of-range chunks
	for (chunkMap_type::iterator it = _chunkMap.begin(); it != _chunkMap.end(); /* No increment */)
	{
		if (it->first.dist_squared_2D(center) > _visibility * _visibility)
		{
			delete it->second;
			it = _chunkMap.erase(it); //returns next element
		}
		else
		{
			it++;
		}
	}

	//load missing chunks
	for (int x = center.x() - _visibility; x <= center.x() + _visibility; x++)
	{
		for (int y = center.y() - _visibility; y <= center.y() + _visibility; y++)
		{
			for (int z = 0; z <= BlockGrid::gridHeight / Chunk::chunkHeight; z++)
			{
				if (z < 0) z = 0; //ensure we don't go too low
				Coords coords(x, y, z);
				if (coords.dist_squared_2D(center) < _visibility * _visibility)
				{
					Coords coords(x, y, z);
					chunkMap_type::iterator it = _chunkMap.find(coords);
					if (it == _chunkMap.end())
					{
						chunkLoader.requestLoadChunk(coords);
						//_dirtyChunks.push_front(chunk);
					}
				}
			}
		}
	}
}
开发者ID:AditGame,项目名称:Adit,代码行数:41,代码来源:ChunkManager.cpp

示例12: addMove

/**
 * Set first move as start move, set newly add move as end move
 * Automatically set move sequence number
 */
void Board::addMove(Coords move) {
    if (moves.empty()) {
        move.m_pointType = PointType::Start;
    } else {
        if (moves.size() >= 2) {
            Coords& lastMove = moves.back();
            lastMove.setMoveType(PointType::Normal);
        }
        move.setMoveType(PointType::End);
    }
    move.m_seq = moves.size() + 1;
    moves.push_back(move);
}
开发者ID:jonathanluo,项目名称:lang,代码行数:17,代码来源:board.cpp

示例13: checkPath

// RECURSION
bool MazeBoard::checkPath(Coords start_pos, Coords end_pos, std::vector<Coords> &open_queue)
{
    if (start_pos == end_pos)
        return true;
    open_queue.push_back(start_pos);

    // expand to right
    if (board[INDEX_C(start_pos)].canGo(RIGHT) && onBoard(start_pos.right())
        && board[INDEX_C(start_pos.right())].canGo(LEFT)
        && notInQueue(start_pos.right(), open_queue)
        && checkPath(start_pos.right(), end_pos, open_queue))
            return true;
    else if (board[INDEX_C(start_pos)].canGo(DOWN) && onBoard(start_pos.down())
        && board[INDEX_C(start_pos.down())].canGo(UP)
        && notInQueue(start_pos.down(), open_queue)
        && checkPath(start_pos.down(), end_pos, open_queue))
            return true;
    else if (board[INDEX_C(start_pos)].canGo(LEFT) && onBoard(start_pos.left())
        && board[INDEX_C(start_pos.left())].canGo(RIGHT)
        && notInQueue(start_pos.left(), open_queue)
        && checkPath(start_pos.left(), end_pos, open_queue))
            return true;
    else if (board[INDEX_C(start_pos)].canGo(UP) && onBoard(start_pos.up())
        && board[INDEX_C(start_pos.up())].canGo(DOWN)
        && notInQueue(start_pos.up(), open_queue)
        && checkPath(start_pos.up(), end_pos, open_queue))
            return true;

    return false;
}
开发者ID:Dasio,项目名称:ICP,代码行数:31,代码来源:MazeBoard.cpp

示例14: containsRing

 bool containsRing(const Coords &other) const {
   return std::all_of(other.begin(), other.end(), [&](const GeoCoordinate &c) {
     return utymap::utils::GeoUtils::isPointInPolygon(c, coordinates.begin(), coordinates.end());
   });
 }
开发者ID:reinterpretcat,项目名称:utymap,代码行数:5,代码来源:MultipolygonProcessor.cpp

示例15: test_DegreeToDecimal

void TestCoord::test_DegreeToDecimal(){


    cutDecLat=cutNumber(mssr_veljav.getDecLatitude());
    cutDecLong=cutNumber(mssr_veljav.getDecLongitude());

    QCOMPARE(cutDecLat,48.26071);
    QCOMPARE(cutDecLong,17.16328);

    cutDecLat=cutNumber(mssr_bucen.getDecLatitude());
    cutDecLong=cutNumber(mssr_bucen.getDecLongitude());

    QCOMPARE(cutDecLat,48.30554);
    QCOMPARE(cutDecLong,19.87072);

    cutDecLat=cutNumber(mie_mor.getDecLatitude());
    cutDecLong=cutNumber(mie_mor.getDecLongitude());

    QCOMPARE(cutDecLat,48.06166);
    QCOMPARE(cutDecLong,17.37638);

    cutDecLat=cutNumber(mich_p37.getDecLatitude());
    cutDecLong=cutNumber(mich_p37.getDecLongitude());

    QCOMPARE(cutDecLat,48.72360);
    QCOMPARE(cutDecLong,21.95121);

    cutDecLat=cutNumber(po_mor5.getDecLatitude());
    cutDecLong=cutNumber(po_mor5.getDecLongitude());

    QCOMPARE(cutDecLat,49.03201);
    QCOMPARE(cutDecLong,21.31433);
}
开发者ID:benoadam,项目名称:Test_Model,代码行数:33,代码来源:test_coord.cpp


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