本文整理汇总了C++中Piece::GetColour方法的典型用法代码示例。如果您正苦于以下问题:C++ Piece::GetColour方法的具体用法?C++ Piece::GetColour怎么用?C++ Piece::GetColour使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piece
的用法示例。
在下文中一共展示了Piece::GetColour方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetPieceAtIndex
void Board::SetPieceAtIndex(Piece &piece, signed char index) {
if (piece.GetColour() == Piece::White) {
for (Piece &p :m_White) {
if (p.GetBoardIndex() == piece.GetBoardIndex()) {
p.SetBoardIndex(index);
}
}
for (Piece &p :m_Black) {
if (p.GetBoardIndex() == index) {
p.SetBoardIndex(127);
}
}
}
if (piece.GetColour() == Piece::Black) {
for (Piece &p :m_Black) {
if (p.GetBoardIndex() == piece.GetBoardIndex()) {
p.SetBoardIndex(index);
}
}
for (Piece &p :m_White) {
if (p.GetBoardIndex() == index) {
p.SetBoardIndex(127);
}
}
}
}
示例2: Board
pair<Move*, MovePieceResult> AI_Jarvis::MakeMove(Board * board, vector<Move *> inputMoves){
vector<pair<int, int>> possibleMoves;
for(int s = 0; s<SQUARE_COUNT; s++){
Piece * piece = board->PieceAtPosition(s);
if(piece != nullptr && piece->GetColour() == colour){
vector<int> * pieceMoves = piece->GetPossibleMoves();
for(int m=0; m<(int)pieceMoves->size(); m++){
Board copyBoard = Board(*board);
if(copyBoard.TestLegalMove(s, pieceMoves->at(m)) == MovePieceResult::OK){
possibleMoves.push_back(make_pair(s, pieceMoves->at(m)));
}
}
delete pieceMoves;
}
}
pair<int, int> randMove = possibleMoves.at(rand() % possibleMoves.size());
pair<Move *, MovePieceResult> result = board->MovePiece(randMove.first, randMove.second);
if(result.second == MovePieceResult::Promote){
Piece * newPiece = board->MakePiece<Queen>(colour, 0);
board->PromotePiece(newPiece);
((Move *)result.first)->SetPawnPromotion(newPiece);
result.second = MovePieceResult::OK;
}
return result;
}