本文整理汇总了C++中Pos::toIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ Pos::toIndex方法的具体用法?C++ Pos::toIndex怎么用?C++ Pos::toIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pos
的用法示例。
在下文中一共展示了Pos::toIndex方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removeStone
void Board::removeStone( Pos const& p )
{
int idx = p.toIndex();
char data = getData( idx );
assert( data != eEmpty );
mData[ idx ] = eEmpty;
for( int dir = 0 ; dir < NumDir ; ++dir )
{
int idxCon = calcConIndex( idx , dir );
char dataCon = mData[ idxCon ];
if ( dataCon == EDGE_MARK || dataCon == eEmpty )
continue;
if ( dataCon & VISITED_MARK )
continue;
if ( dataCon != data )
{
addRootLife( getLinkRoot( idxCon ) , 1 );
}
else
{
relink( idxCon );
}
}
for( int dir = 0 ; dir < NumDir ; ++dir )
{
int idxCon = calcConIndex( idx , dir );
if ( mData[ idxCon ] & VISITED_MARK )
removeVisitedMark_R( idxCon );
}
}
示例2: fillStone
int Board::fillStone( Pos const& p , DataType color )
{
mColorR = color;
assert( color != eEmpty );
int idx = p.toIndex();
return fillStone_R( idx );
}
示例3: play
bool Game::play( Pos const & pos )
{
if ( mBoard.getData( pos ) != Board::eEmpty )
return false;
mBoard.putStone( pos , mNextPlayColor );
unsigned bitDir = 0;
int numCapture = captureStone( pos , bitDir );
if ( numCapture == 0 )
{
if ( mBoard.getLife( pos ) == 0 )
{
mBoard.removeStone( pos );
return false;
}
}
else if ( numCapture == 1 )
{
if ( pos.toIndex() == mIdxKoPos )
{
Pos cPos = getFristConPos( pos , bitDir );
mBoard.fillStone( cPos , mNextPlayColor == Board::eBlack ? Board::eWhite : Board::eBlack );
mBoard.removeStone( pos );
return false;
}
}
StepInfo info;
info.bitCaptureDir = bitDir;
info.idxPlay = pos.toIndex();
info.idxKO = mIdxKoPos;
mStepVec.push_back( info );
if ( numCapture == 1 )
{
Pos cPos = getFristConPos( pos , bitDir );
mIdxKoPos = cPos.toIndex();
}
else
{
mIdxKoPos = -1;
}
++mCurHand;
if ( mNextPlayColor == Board::eBlack )
{
mNumWhiteRemoved += numCapture;
mNextPlayColor = Board::eWhite;
}
else
{
mNumBlackRemoved += numCapture;
mNextPlayColor = Board::eBlack;
}
return true;
}
示例4: captureStone
int Board::captureStone( Pos const& p )
{
mColorR = getData( p );
assert( mColorR != eEmpty );
return captureStone_R( p.toIndex() );
}