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


C++ Pos::toIndex方法代码示例

本文整理汇总了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 );
		}
	}
开发者ID:uvbs,项目名称:GameProject,代码行数:35,代码来源:GoCore.cpp

示例2: fillStone

	int Board::fillStone( Pos const& p , DataType color )
	{
		mColorR = color;
		assert( color != eEmpty );
		int idx = p.toIndex();
		return fillStone_R( idx );
	}
开发者ID:uvbs,项目名称:GameProject,代码行数:7,代码来源:GoCore.cpp

示例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;
	}
开发者ID:uvbs,项目名称:GameProject,代码行数:61,代码来源:GoCore.cpp

示例4: captureStone

	int Board::captureStone( Pos const& p )
	{
		mColorR = getData( p );
		assert( mColorR != eEmpty );
		return captureStone_R( p.toIndex() );
	}
开发者ID:uvbs,项目名称:GameProject,代码行数:6,代码来源:GoCore.cpp


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