本文整理汇总了C++中Moves::append方法的典型用法代码示例。如果您正苦于以下问题:C++ Moves::append方法的具体用法?C++ Moves::append怎么用?C++ Moves::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Moves
的用法示例。
在下文中一共展示了Moves::append方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generatePawnMoves
void ChessBoard::generatePawnMoves(ChessBoard& board, int sqSrc, Moves& mvs)
{
int sqDst;
if (board.m_sdPlayer != SQ_SIDE(sqSrc))
{
sqDst = sqSrc - 1;
if (IN_BOARD(sqDst) && board.canMove(board, sqSrc, sqDst))
{
mvs.append(ChessBoard::mv(sqSrc, sqDst));
}
sqDst = sqSrc + 1;
if (IN_BOARD(sqDst) && board.canMove(board, sqSrc, sqDst))
{
mvs.append(ChessBoard::mv(sqSrc, sqDst));
}
}
if (board.m_sdPlayer==0)
{
sqDst = sqSrc - 16;
}
else{
sqDst = sqSrc + 16;
}
if (IN_BOARD(sqDst) && board.canMove(board, sqSrc, sqDst))
{
mvs.append(ChessBoard::mv(sqSrc, sqDst));
}
}
示例2: movementOptions
UltimateTicTacToeMontecarloAI::Moves UltimateTicTacToeMontecarloAI::movementOptions(Board const& board, int const previousMove) const
{
int gridIndex = previousMove % GRID_SIZE;
bool playAny = previousMove < 0 || gridWinner(board.grids, gridIndex) || gridFull(board.grids, gridIndex);
Moves options;
if(playAny)
{
for(int i = 0; i < BOARD_SIZE; ++i)
{
if(board.grids.at(i) == 0)
{
options.append(i);
}
}
//qDebug() << "Play to any grid," << options.size() << "options";
}
else
{
for(int i = 0; i < GRID_SIZE; ++i)
{
int position = gridIndex * GRID_SIZE + i;
if(board.grids.at(position) == 0)
{
options.append(position);
}
}
//qDebug() << "Play to grid" << gridIndex << "," << options.size() << "options";
}
return options;
}
示例3: generateCannonMoves
void ChessBoard::generateCannonMoves(ChessBoard& board, int sqSrc, Moves& mvs)
{
static const int delta[4] = {-16, -1, 1, 16};
for(int i=0; i<4; i++)
{
int sqDst = sqSrc;
bool skiped = false;
while (true)
{
sqDst += delta[i];
if (!IN_BOARD(sqDst)) break;
if (!board.m_data[sqDst])
{
if (!skiped)
{
mvs.append(ChessBoard::mv(sqSrc, sqDst));
}
}
else{
if (!skiped)
{
skiped = true;
}
else{
int pc = board.m_data[sqDst];
if (pc!=0)
{
if (board.canMove(board, sqSrc, sqDst))
{
mvs.append(ChessBoard::mv(sqSrc, sqDst));
}
}
break;
}
}
}
}
}
示例4: generateRookMoves
void ChessBoard::generateRookMoves(ChessBoard& board, int sqSrc, Moves& mvs)
{
static const int delta[4] = {-16, -1, 1, 16};
for(int i=0; i<4; i++)
{
int sqDst = sqSrc;
while (true)
{
sqDst += delta[i];
if (!IN_BOARD(sqDst)) break;
if (!board.m_data[sqDst])
{
mvs.append(ChessBoard::mv(sqSrc, sqDst));
}
else{
if (board.canMove(board, sqSrc, sqDst))
{
mvs.append(ChessBoard::mv(sqSrc, sqDst));
}
break;
}
}
}
}
示例5: generateAdvisorMoves
void ChessBoard::generateAdvisorMoves(ChessBoard& board, int sqSrc, Moves& mvs)
{
static const int ccAdvisorDelta[4] = {-17, -15, 15, 17};
for(int i=0; i<4; i++)
{
int sqDst = sqSrc + ccAdvisorDelta[i];
if (IN_FORT(sqDst))
{
if (board.canMove(board, sqSrc, sqDst))
{
mvs.append(ChessBoard::mv(sqSrc, sqDst));
}
}
}
}
示例6: generateKingMoves
void ChessBoard::generateKingMoves(ChessBoard& board, int sqSrc, Moves& mvs)
{
static const int ccKingDelta[4] = {-16, -1, 1, 16};
for(int i=0; i<4; i++)
{
int sqDst = sqSrc + ccKingDelta[i];
if (IN_FORT(sqDst))
{
if (board.canMove(board, sqSrc, sqDst))
{
mvs.append(ChessBoard::mv(sqSrc, sqDst));
}
}
}
}
示例7: generateBishopMoves
void ChessBoard::generateBishopMoves(ChessBoard& board, int sqSrc, Moves& mvs)
{
static const int ccBishopDelta[4] = {-34, -30, 30, 34};
static const int ccBishopPin[4] = {-17, -15, 15, 17};
for(int i=0; i<4; i++)
{
int sqDst = sqSrc + ccBishopDelta[i];
if (!IN_BOARD(sqDst)) continue;
int sqPin = sqSrc + ccBishopPin[i];
if (board.m_data[sqPin]) continue;
if (SAME_HALF(sqSrc, sqDst))
{
if (board.isInBoard(sqDst) && board.canMove(board, sqSrc, sqDst))
{
mvs.append(ChessBoard::mv(sqSrc, sqDst));
}
}
}
}
示例8: generateKnightMoves
void ChessBoard::generateKnightMoves(ChessBoard& board, int sqSrc, Moves& mvs)
{
static const int ccKingDelta[4] = {-16, -1, 1, 16};
static const int ccKnightDelta[4][2] = {{-33, -31}, {-18, 14}, {-14, 18}, {31, 33}};
for (int i=0; i<4; i++)
{
int sqPin = sqSrc + ccKingDelta[i];
if (IN_BOARD(sqPin) && board.m_data[sqPin]==0)
{
//马腿没有东西
for(int j=0; j<2; j++)
{
int sqDst = sqSrc + ccKnightDelta[i][j];
if (board.isInBoard(sqDst) && board.canMove(board, sqSrc, sqDst))
{
mvs.append(ChessBoard::mv(sqSrc, sqDst));
}
}
}
}
}